<template>
  <div>
    <el-row v-show="ifShowMain">
      <el-col ref="layoutTemplate" v-if="diagnosisTemplateVisible" :span="layoutTemplateCol">
        <el-tabs v-model="diagnosisTemplateTabActive" @tab-click="diagnosisTemplateTabChange" type="card">
          <el-tab-pane label="机构模板" name="orgTemplate" style="padding-top: 10px"></el-tab-pane>
          <el-tab-pane label="我的模板" name="myTemplate" style="padding-top: 10px"></el-tab-pane>
        </el-tabs>
        <!-- <el-row>
                    <el-input
                        v-model="diagnosisTemplateFilterKey"
                        placeholder="请输入关键字"
                        class="input-form"
                        size="mini"
                    >
                    </el-input>
                    <el-button
                        @click="diagnosisTemplateFilter"
                        size="mini"
                        class="button-list-item"
                    >
                        过滤
                    </el-button>
                </el-row>
                <el-tree
                    node-key="id"
                    v-loading="!isDiagnosisTemplateReady"
                    :data="diagnosisTemplateList"
                    :props="diagnosisTemplateProps"
                    :load="diagnosisTemplateLoad"
                    :default-expanded-keys="diagnosisExpandList"
                    accordion
                    :lazy="true"
                >
                    <span
                        slot-scope="{ node, data }"
                        class="diagnosis-template-tree"
                    >
                        <span class="diagnosis-template-tree-message">
                            <el-button
                                @click="diagnosisTemplateNodeClick(data, node)"
                                size="mini"
                                type="text"
                                style="color: #000"
                                :title="node.data.diagnoseLook"
                            >
                                {{ node.label }}
                            </el-button>
                            <el-button
                                v-if="isShowInstitutionTemplates"
                                v-show="!node.data.isLeaf"
                                @click="diagnosisTemplateNodeCopy(node)"
                                size="mini"
                                type="text"
                            >
                                复制
                            </el-button>
                        </span>
                    </span>
        </el-tree>-->
        <el-row>
          <el-input v-model="filterText" placeholder="请输入关键字" class="input-form" size="mini"></el-input>
        </el-row>
        <el-tree class="filter-tree" v-loading="!isDiagnosisTemplateReady" :data="diagnosisTemplateData"
          :props="diagnosisTemplateProps" default-expand-all :filter-node-method="filterNode" ref="tree">
          <div slot-scope="{ node, data }" class="diagnosis-template-tree">
            <span class="diagnosis-template-tree-message">
              <el-button @click="diagnosisTemplateNodeClick(data, node)" size="mini" type="text" style="color: #000"
                :title="node.data.diagnoseLook">
                <span>{{ node.label }}</span>
              </el-button>
              <el-button v-if="isShowInstitutionTemplates" v-show="!node.data.isLeaf"
                @click="diagnosisTemplateNodeCopy(node)" size="mini" type="text">复制</el-button>
            </span>
          </div>
        </el-tree>
      </el-col>

      <el-col ref="layoutMain" :span="layoutMainCol" style="padding: 0 10px">
        <el-row  type="flex" align="middle" class="h40">
          <!-- 模板显示按钮 -->
          <el-button @click="diagnosisTemplateVisibleChange" size="mini" class="button-list-item">
            {{ diagnosisTemplateVisible ? '收起' : '模板' }}
          </el-button>
          <!--病理编号搜索-->
          <el-input v-model="searchPathologyId" placeholder="病理编号" class="input-form redcolor-input"
             size="mini"></el-input>
          <el-button @click="diagnosisSearch" class="button-list-item" type="primary" size="mini">搜索</el-button>
          <el-button @click="diagnosisLast" :disabled="!prevPathologyId" class="button-list-item" type="primary"
            size="mini">上一个</el-button>
          <el-button @click="diagnosisNext" :disabled="!nextPathologyId" class="button-list-item" type="primary"
            size="mini">下一个</el-button>
          <!--状态-->
          <el-tag size="mini" :type="finishType" class="ml10" >{{ levelLabel }}</el-tag>
          <!--TODO 打印数量-->
          <!-- <el-tag
                        v-if="isFinished"
                        size="mini"
                        type="danger"
                        class="tag-list-item"
                    >
                        {{ "未打印" }}
          </el-tag>-->
          <!--是否收藏-->
          <el-tag size="mini" :type="collectionTagType" class="ml10">{{
            isCollected ? '已收藏' : '未收藏'
          }}</el-tag>
          <!--TODO 倒计时-->
          <el-tag v-if="isShowDeadline" :type="tagDeadlineType" size="mini" class="tag-list-item">{{ '已超时' }}</el-tag>
          <el-tag v-if="reportResultTextShow" size="mini" class="tag-list-item ml10" >{{
            isSuccessSubmitReportResult }}</el-tag>
          <!-- 智能分析显示按钮 -->
          <!-- <el-button
                        @click="isShowLayoutAiInfo = !isShowLayoutAiInfo"
                        size="mini"
                        class="button-list-item"
                    >
                        {{ isShowLayoutAiInfo ? "收起" : "智能分析" }}
          </el-button>-->
          <!--TODO-->
          <!-- <el-button
                        @click="diagnosisCheckAnalysis"
                        size="mini"
                        class="button-list-item"
                    >
                        检验分析
          </el-button>-->
          <el-tag :size="diagnosisLevel === 1 ? '' : 'mini'"
            style=" background-color: grey; color: #000"
            :class="diagnosisLevel === 1 ? 'activeRedBorder' : 'tag-default-calss'">待</el-tag>
          <el-tag :size="diagnosisLevel === 2 ||
            diagnosisLevel === 3 ||
            diagnosisLevel === 4 ||
            diagnosisLevel === 5
            ? ''
            : 'mini'
            " 
            style=" background-color: #a5cbf0; color: #000" :class="diagnosisLevel === 2 ||
    diagnosisLevel === 3 ||
    diagnosisLevel === 4 ||
    diagnosisLevel === 5
    ? 'activeRedBorder'
    : 'tag-default-calss'
    ">写</el-tag>
          <el-tag :size="diagnosisLevel === 6 ? '' : 'mini'"
            style=" background-color: #a3ea4d; color: #000"
            :class="diagnosisLevel === 6 ? 'activeRedBorder' : 'tag-default-calss'">审</el-tag>
          <el-tag size="mini" style=" background-color: #facb07; color: #000" class="tag-default-calss">延</el-tag>
          <el-tag size="mini" style=" background-color: red; color: #000" class="tag-default-calss">超</el-tag>
          <el-tag size="mini" style=" background-color: #a495c3; color: #000" class="tag-default-calss">印</el-tag>
          
        </el-row>
        <el-row  type="flex" align="middle" class="h40 overx-scroll">
          <el-tooltip placement="top" effect="light">
            <div slot="content">
              <el-badge :value="specialExtraCount" :hidden="specialExtraCount === 0" style="margin-right: 10px; z-index: 2">
                <el-button @click="specialExtraDialogOpen" :disabled="!canAddExtraProject" type="primary" size="mini"
                  >特殊医嘱</el-button>
              </el-badge>
              <el-badge :value="techExtraCount" :hidden="techExtraCount === 0" style="z-index: 1">
                <el-button @click="techExtraDialogOpen" :disabled="!canAddExtraProject" type="primary" size="mini"
                  >技术医嘱</el-button>
              </el-badge>
            </div>
            <el-button size="mini" type="primary">医嘱</el-button>
          </el-tooltip>
          <!--TODO-->
          <!-- <el-button
                        @click="diagnosisRescan"
                        size="mini"
                        class="button-list-item"
                        type="primary"
                        style="margin-right: 20px"
                    >
                        重新扫描
          </el-button>-->
          <!--TODO-->
          <!-- v-if="diagnosisLevel > 3" :disabled="!isThisDoctor" -->
          <el-tooltip placement="top" effect="light">
            <div slot="content">
              <el-button v-if="isDivisionConsultationApplyPermissions" @click="diagnosisDiscussion(0)" size="mini"
                class="button-list-item" type="primary">科内会诊</el-button>
              <el-button v-if="isOutsideConsultationApplyPermissions" @click="diagnosisSendOut(1)" size="mini"
                class="button-list-item" type="primary">院外会诊</el-button>
            </div>
            <el-button size="mini" type="primary">会诊</el-button>
          </el-tooltip>
          <el-tooltip placement="top" effect="light">
            <div slot="content">
              <el-button v-if="isThisDoctor" :disabled="!isThisOpinionTab || isFinished" @click="doctorsDialogOpen"
                size="mini" class="button-list-item" type="primary" v-show="!isInvited">邀 请</el-button>
              <el-button type="primary" size="mini" class="button-list-item" @click="shareQRCode">分享二维码</el-button>
            </div>
            <el-button size="mini" type="primary">邀请</el-button>
          </el-tooltip>
          <el-tooltip placement="top" effect="light">
            <div slot="content">
              <el-button type="primary" size="mini" class="button-list-item" @click="addTeachingLibrary">+教学库</el-button>
              <el-button type="primary" size="mini" class="button-list-item" @click="addScienceLibrary">+科研库</el-button>
              <el-button @click="collectChange" type="primary" size="mini" class="button-list-item">{{ isCollected ? '取消收藏' :
                '收 藏' }}</el-button>
            </div>
            <el-button size="mini" type="primary">收藏</el-button>
          </el-tooltip>
          <el-button v-if="isThisDoctor && !isInvited" :disabled="tumorReport" @click="btnTumorReport"
            v-show="issueButtonVisible || auditButtonVisible || finalVerifyButtonVisible" size="mini"
            class="button-list-item tag-default-calss" type="primary">
            肿瘤请报告
          </el-button>
          <el-button v-if="isThisDoctor" :disabled="!isThisOpinionTab || isFinished" @click="diagnosisSave" size="mini"
            class="button-list-item save-btn" type="text"  icon="el-icon-document-add">保 存</el-button>
          <el-button
            v-if="(diagnosis.diagnosisDetailList.length > 0 ? diagnosis.diagnosisDetailList[0].doctorId : '') === userId"
            :disabled="!isThisOpinionTab" @click="diagnosisCommitUpdate" v-show="diagnosisLevel === 3 && !isInvited"
            size="mini" class="button-list-item save-btn" type="text" icon="el-icon-edit-outline">修改提交</el-button>
          <el-button v-if="isThisDoctor" :disabled="!isThisOpinionTab" @click="diagnosisCommit"
            v-show="submitButtonVisible && !isInvited" size="mini" class="button-list-item save-btn" type="text"
             icon="el-icon-tickets">提 交</el-button>
          <el-button v-if="isFinished" :disabled="!isThisDoctor" @click="reportCallBack" type="primary" size="mini"
            class="button-list-item">
            取消审核
            <!-- 回收报告 -->
          </el-button>
          <el-button v-if="isFinished" @click="reportView" size="mini" type="primary"
            class="button-list-item">查看报告</el-button>
          <el-button v-if="isFinished" :disabled="!isThisDoctor" @click="reportDelay" type="primary" size="mini"
            class="button-list-item">延期报告</el-button>
          <el-button v-if="isThisDoctor && !isInvited" :disabled="!isThisOpinionTab" @click="diagnosisIssue"
            v-show="issueButtonVisible" size="mini" class="button-list-item save-btn" type="text" icon="el-icon-document-checked">
            审核
            <!-- 核发报告 -->
          </el-button>
          <el-button v-if="isThisDoctor" :disabled="!isThisOpinionTab" @click="diagnosisAudit" v-show="auditButtonVisible"
            size="mini" class="button-list-item save-btn" type="text" icon="el-icon-document-checked">审核</el-button>
          <el-button v-if="isThisDoctor" :disabled="!isThisOpinionTab" @click="diagnosisFinalVerify"
            v-show="finalVerifyButtonVisible" size="mini" class="button-list-item save-btn" type="text">终审报告</el-button>
          <el-button v-if="isThisDoctor" :disabled="!isThisOpinionTab || isFinished" @click="diagnosisSendBack"
            size="mini" class="button-list-item save-btn" type="text" v-show="!isInvited">退 回</el-button>
        </el-row>
        <el-form ref="qualityForm" v-model="qualityForm" label-width="80px" :inline="true">
          <el-row>
            <el-col :xs="12" :sm="12" :md="12" :lg="4" :xl="4" >
              <el-form-item label="冰冻符合:">
                <el-select v-model="qualityForm.frozenCoincidenceRate" placeholder="请选择冰冻符合率" size="mini"
                  class="quality-list-item">
                  <el-option v-for="t in frozenCoincidenceRateList" :key="t.id" :label="t.label"
                    :value="t.label"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="12" :sm="12" :md="12" :lg="4" :xl="4">
              <el-form-item label="诊断符合:">
                <el-select v-model="qualityForm.diagnosticAccordanceRate" placeholder="请选择诊断符合率" size="mini"
                  class="quality-list-item">
                  <el-option v-for="t in diagnosticAccordanceRateList" :key="t.id" :label="t.label"
                    :value="t.label"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="12" :sm="12" :md="12" :lg="4" :xl="4">
              <el-form-item label="诊断细致:">
                <el-select v-model="qualityForm.diagnosticCarefulnessRate" placeholder="请选择诊断细致性" size="mini"
                  class="quality-list-item">
                  <el-option v-for="t in DiagnosticCarefulnessRateList" :key="t.id" :label="t.label"
                    :value="t.label"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="12" :sm="12" :md="12" :lg="4" :xl="4">
              <el-form-item label="切片质量:">
                <el-select v-model="qualityForm.biopsyQuality" placeholder="请选择切片质量" size="mini"
                  class="quality-list-item">
                  <el-option v-for="t in biopsyQualityList" :key="t.id" :label="t.label" :value="t.label"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="12" :sm="12" :md="12" :lg="4" :xl="4">
              <el-form-item label="扫描质量:">
                <el-select v-model="qualityForm.scanQuality" placeholder="请选择扫描质量" size="mini" class="quality-list-item">
                  <el-option v-for="t in scanQualityList" :key="t.id" :label="t.label" :value="t.label"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-row>
          <el-form>
            <el-form-item label="检查类型:">
              <el-select v-model="checkCategorySelected" placeholder="请选择检查类型" @change="checkCategoryChange"
                :disabled="!isFirstOpinion" size="mini" style="width: 210px">
                <el-option v-for="item in checkCategoryList" :key="item.id" :label="item.name"
                  :value="item.id"></el-option>
              </el-select>
              <el-button size="mini">
                <font-awesome-icon :icon="['fas', 'microphone']"></font-awesome-icon>
                {{ ` 语音录入` }}
              </el-button>
              <el-button size="mini" icon="el-icon-document">语音上传</el-button>
            </el-form-item>
          </el-form>
        </el-row>
        <div ref="baseInfo" style="font-size: 12px">
          <el-row>
            <el-col v-for="info in baseInfoList" :key="info.key" class="ellipsis" :xs="12" :sm="8" :md="8" :lg="4" :xl="4">
              <span :title="info.value">{{ info.label }}{{ info.value }}</span>
            </el-col>
          </el-row>
        </div>
        <div v-if="!isAssigned">未分配</div>
        <div v-else>
          <el-row v-if="reportTemplateReady" style="margin-top: 10px" align="middle" type="flex" justify="space-between">
            <el-tabs v-model="opinionTabActive" type="card" ref="diagnosisLevelTabs" :before-leave="opinionTabChange">
              <el-tab-pane v-for="item of opinionTabList" :label="item.tabLabel" :name="item.name.toString()"
                :key="item.name.toString()"></el-tab-pane>
            </el-tabs>
            <el-button @click="diagnosisCopy" align="right" type="text" size="mini" v-if="isThisDoctor"
              :disabled="isThisOpinionTab || isFinished">复制{{ beClickedDoctor }}病理诊断</el-button>
          </el-row>

          <el-row v-if="annotationsList.length > 0" type="flex" justify="center">
            <div class="annotation-row">
              <span>病理图像:</span>
              <div>
                <img v-for="(item, index) in annotationsList" class="annotation-img" :src="item.imageUrl"
                  @click="OpenImage(item.imageUrl)" :key="index" alt />
              </div>
            </div>
          </el-row>
          <el-row justify="start">
            <div class="annotation-row1" :title="diagnosis.pathologySummary">
              <span class="row1-red">病史摘要:</span>
              <span class="pathology-observed-text">{{
                diagnosis.pathologySummary
              }}</span>
            </div>
            <div class="annotation-row1" :title="diagnosis.pathologyObserved">
              <span class="row1-red">大体巨检:</span>
              <span class="pathology-observed-text">{{
                diagnosis.pathologyObserved
              }}</span>
            </div>
          </el-row>
          <div class="container-bottom">
            <el-row>
              <el-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
                <div v-if="reportTemplateReady" class="container-narrow">
                  <grid-layout id="custom-report" :layout.sync="componentList" :col-num="reportTemplateCol"
                    :row-height="28" :is-draggable="false" :is-resizable="false" :is-mirrored="false"
                    :vertical-compact="true" :use-css-transforms="true">
                    <grid-item v-for="(item, index) in componentList" :x="item.x" :y="item.y" :w="item.w" :h="item.h"
                      :i="item.i" :key="index">
                      <el-row v-if="item.smallType === 'space'" class="row-in-grid-item"></el-row>

                      <hr v-else-if="item.smallType === 'hr'" />

                      <el-row v-else-if="item.smallType === 'text'" class="row-in-grid-item">
                        <span :style="styleString(item.styleJson)">{{ item.stringContent }}</span>
                      </el-row>
                      <!-- @click="aiValueToAssign(item.stringContent)" -->

                      <el-row v-else-if="item.smallType === 'input'" class="row-in-grid-item">
                        <div :id="item.i" style="width: 100%; height: 100%">
                          <el-input v-if="item.isInputArea" type="textarea" v-model="detailForm[item.i]" :autosize="{
                            minRows: 1,
                            maxRows: parseInt((item.h * 5) / 3, 10),
                          }" :placeholder="item.placeholder" :style="styleString(item.styleJson)"
                            :disabled="!isThisOpinionTab || isFinished" size="mini"></el-input>
                          <el-input v-else v-model="detailForm[item.i]" :placeholder="item.placeholder"
                            :style="styleString(item.styleJson)" :disabled="!isThisOpinionTab || isFinished"
                            :readonly='diagnosisStomachSample' size="mini" @focus="aiValueToAssign(item.name)"></el-input>
                        </div>
                      </el-row>

                      <el-row v-else-if="item.smallType === 'selection'" class="row-in-grid-item">
                        <div :id="item.i" style="width: 100%; height: 100%">
                          <el-select
                            v-if="item.name == '部位1' || item.name == '部位2' || item.name == '部位3' || item.name == '部位4' || item.name == '部位5' || item.name == '部位6'"
                            v-model="detailForm[item.i]" :placeholder="item.placeholder"
                            :style="styleString(item.styleJson)"
                            :disabled="!isThisOpinionTab || isFinished || diagnosisStomachSample" size="mini" clearable>
                            <el-option v-for="(t, index) in item.selectDataJson" :key="index" :label="t"
                              :value="t"></el-option>
                          </el-select>
                          <el-select v-else v-model="detailForm[item.i]" :placeholder="item.placeholder"
                            :style="styleString(item.styleJson)" :disabled="!isThisOpinionTab || isFinished" size="mini"
                            clearable>
                            <el-option v-for="(t, index) in item.selectDataJson" :key="index" :label="t"
                              :value="t"></el-option>
                          </el-select>
                        </div>
                      </el-row>

                      <el-row v-else-if="item.smallType === 'special'" class="row-in-grid-item">
                        <!--病理图像判断-->
                        <div v-if="item.i === 'special_normal_pathologyFiles'" style="width: 100%; height: 100%">
                          <span style="float: left">{{
                            item.stringContent
                          }}</span>
                        </div>
                        <!--签名图像-->
                        <div v-else-if="item.i === 'special_base_reportDoctor'">
                          <span>
                            {{ item.stringContent }}
                          </span>
                        </div>
                        <!--特殊检查-导入-->
                        <div v-else-if="item.i === 'special_normal_import'" style="margin-left: 10px">
                          <el-button size="mini" type="text" @click="detailSpecialCheckImport">{{ item.stringContent
                          }}</el-button>
                        </div>
                        <div v-else-if="item.i === 'special_clearable_microFingings'
                          " style="margin-left: 10px">
                          <el-button size="mini" type="text" :disabled="!isThisOpinionTab || isFinished"
                            @click="detailMicroFingingsClear">{{ item.stringContent }}</el-button>
                        </div>
                        <div v-else-if="item.i === 'special_clearable_specialCheck'
                          " style="margin-left: 10px">
                          <el-button size="mini" type="text" :disabled="!isThisOpinionTab || isFinished"
                            @click="detailSpecialCheckClear">{{ item.stringContent }}</el-button>
                        </div>
                        <div v-else-if="item.i === 'special_clearable_diagnose'" style="margin-left: 10px">
                          <el-button size="mini" type="text" :disabled="!isThisOpinionTab || isFinished"
                            @click="detailDiagnoseClear">{{ item.stringContent }}</el-button>
                        </div>
                      </el-row>
                    </grid-item>
                  </grid-layout>
                </div>
              </el-col>
              <el-col :xs="24" :sm="24" :md="24" :lg="6" :xl="6">
                <div v-if="reportTemplateReady" class="container-right">
                  <discussion :messageList="diagnosis.messageBoardList" :isTheseDoctor="isTheseDoctor"
                    :diagnosis="diagnosis"></discussion>
                </div>
              </el-col>
            </el-row>
          </div>
        </div>
      </el-col>

      <!--TODO-->
      <el-col ref="layoutAiInfo" v-if="isShowLayoutAiInfo" :span="layoutAiInfoCol" style="float: right">
        <el-card shadow="hover">智能分析</el-card>
      </el-col>
    </el-row>
    <!-- <opinion-bottom :diagnosis="diagnosis"
                        ref="bottom"
                        @drawECharts="getPicData"
                        @showMain="changeShowMain">
    </opinion-bottom>-->
    <el-dialog :title="submitDialog.title" :visible.sync="submitDialog.visible" :close-on-click-modal="false"
      :modal-append-to-body="false" append-to-body width="90%">
      <base-table ref="submitTable" v-loading="!submitDialog.isReady" :data="submitTable.data"
        :header="submitTable.header" :operation="submitTable.operation" :pageInfo="submitTable.pageInfo"
        :pageSizes="[10, 15, 20]" @pageJumpTo="submitTablePageJumpTo" @sizeChange="submitTableSizeChange"
        @handleClick="submitTableButtonClick"></base-table>
      <span slot="footer" class="dialog-footer" style="text-align: right">
        <el-button @click="submitDialog.visible = false" size="mini">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog :title="specialAdviceDialog.title" :visible.sync="specialAdviceDialog.visible"
      :close-on-click-modal="false" :modal-append-to-body="false" :before-close="specialAdviceDialogClose" append-to-body
      width="90%">
      <diagnosis-special-advice ref="specialAdvice" :data="diagnosis"
        :permission="extraProjectPermission"></diagnosis-special-advice>
      <span slot="footer" class="dialog-footer" style="text-align: right">
        <el-button @click="specialAdviceDialogClose" size="mini">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog :title="techAdviceDialog.title" :visible.sync="techAdviceDialog.visible" :close-on-click-modal="false"
      :modal-append-to-body="false" :before-close="techAdviceDialogClose" append-to-body width="90%">
      <diagnosis-tech-advice ref="techAdvice" :data="diagnosis"
        :permission="extraProjectPermission"></diagnosis-tech-advice>
      <span slot="footer" class="dialog-footer" style="text-align: right">
        <el-button @click="techAdviceDialogClose" size="mini">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" v-loading="picLoading" title="检验指标趋势图" :visible.sync="PICdialogVisible"
      width="80%">
      <el-form :model="picForm" :inline="true">
        <el-form-item label="选择检验项">
          <el-select v-model="PicSelectionItemsData" placeholder="选择检验项" size="mini" clearable
            @change="PicSelectionItemschange">
            <el-option v-for="item in SelectionItemsData" :key="item.value" :label="item.label"
              :value="item.value"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div id="examLevel" style="height: 300px"></div>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" type="primary" @click="PICdialogVisible = false">关 闭</el-button>
      </span>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="邀请专家" :visible.sync="doctorsDialog.visible" width="90%"
      append-to-body>
      <div class="invite-y-scroll">
        <base-table v-loading="!doctorsTable.isReady" ref="doctorsTable" :data="doctorsTable.data"
          :header="doctorsTable.header" :selected="doctorsTable.selected" :operation="doctorsTable.operation"
          :pageInfo="doctorsTable.pageInfo" :pageSizes="[10, 15, 20]" @selectionChange="selectionChange"
          @handleSelectAll="handleSelectAll" @handleClick="doctorsTableButtonClick" @pageJumpTo="doctorsTablePageJumpTo"
          @sizeChange="doctorsTableSizeChange"></base-table>
      </div>
      <el-row style="margin-top: 10px" type="flex" justify="end">
        <el-button @click="batchInvite" size="mini" type="primary">邀请</el-button>
        <el-button @click="doctorsDialog.visible = false" size="mini">取消</el-button>
      </el-row>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="我的科研库" :visible.sync="scienceLibraryDialog.visible" width="70%"
      append-to-body>
      <div class="invite-y-scroll">
        <base-table v-loading="!scienceLibraryTable.isReady" ref="scienceLibraryTable" :data="scienceLibraryTable.data"
          :header="scienceLibraryTable.header" :selected="scienceLibraryTable.selected"
          @selectionChange="scienceLibrarySelectionChange" @handleSelectAll="scienceLibraryHandleSelectAll"
          :operation="scienceLibraryTable.operation" :pageInfo="scienceLibraryTable.pageInfo" :pageSizes="[5, 10, 15, 20]"
          @pageJumpTo="scienceLibraryTablePageJumpTo" @sizeChange="scienceLibraryTableSizeChange"></base-table>
      </div>
      <el-row style="margin-top: 10px" type="flex" justify="end">
        <el-button @click="btnScienceLibrary" size="mini" type="primary">入库</el-button>
        <el-button @click="scienceLibraryDialog.visible = false" size="mini">取消</el-button>
      </el-row>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="我的教学库" :visible.sync="teachingLibraryDialog.visible" width="70%"
      append-to-body>
      <div class="invite-y-scroll">
        <base-table v-loading="!teachingLibraryTable.isReady" ref="teachingLibraryTable" :data="teachingLibraryTable.data"
          :header="teachingLibraryTable.header" :selected="teachingLibraryTable.selected"
          @selectionChange="teachingLibrarySelectionChange" @handleSelectAll="teachingLibraryHandleSelectAll"
          :operation="teachingLibraryTable.operation" :pageInfo="teachingLibraryTable.pageInfo"
          :pageSizes="[5, 10, 15, 20]" @pageJumpTo="teachingLibraryTablePageJumpTo"
          @sizeChange="teachingLibraryTableSizeChange"></base-table>
      </div>
      <el-row style="margin-top: 10px" type="flex" justify="end">
        <el-button @click="btnTeachingLibrary" size="mini" type="primary">入库</el-button>
        <el-button @click="teachingLibraryDialog.visible = false" size="mini">取消</el-button>
      </el-row>
    </el-dialog>
    <el-dialog title="分享二维码" :visible.sync="shareDialogVisible" width="30%">
      <el-row>{{ shareName }}医生邀请您查看这个病人的详情</el-row>
      <el-row style="margin-top: 15px">操作方法：微信中识别图中二维码-点击右上角三个点--在浏览器中打开（打开手机的自动旋转功能，观看效果更好）</el-row>
      <div class="share-qrcode-box">
        <vue-qr :logo-src="logoSrc" :size="140" :margin="0" :auto-color="true" :dot-scale="1" :text="appSrc" />
      </div>
    </el-dialog>
  </div>
</template>

<script>
import _ from 'lodash';
import VueGridLayout from 'vue-grid-layout';
import BaseTable from '@templates/components/BaseTable';
import diagnosisDefaultBase from '@templates/diagnosisDefault';
import DiagnosisSpecialAdvice from '@templates/components/DiagnosisSpecialAdvice';
import DiagnosisTechAdvice from '@templates/components/DiagnosisTechAdvice';
import moment from 'moment';
import OpinionBottom from './OpinionBottom';
import VueQr from 'vue-qr';
import Discussion from './diagnosisDetailDiscussion'; //将讨论留言放入诊断意见内

const echarts = require('echarts');

const diagnosisDefault = _.clone(diagnosisDefaultBase);
diagnosisDefault.collectionId = 0;

const userLevelBase = [
  {
    level: 2,
    label: '初诊',
  },
  {
    level: 3,
    label: '核发',
  },
  {
    level: 4,
    label: '审核',
  },
  {
    level: 5,
    label: '终审',
  },
];
// 加做类型
const doctorAdviceMapBase = [
  {
    key: 'ss',
    type: 1,
    label: '特殊染色',
    isWithPackage: false,
  },
  {
    key: 'mo',
    type: 2,
    label: '分子病理',
    isWithPackage: true,
  },
  {
    key: 'ihc',
    type: 3,
    label: '免疫组化',
    isWithPackage: true,
  },
  {
    key: 'tec',
    type: 4,
    label: '技术医嘱',
    isWithPackage: false,
  },
];
export default {
  name: 'DiagnosisDetailOpinion',
  components: {
    OpinionBottom,
    GridLayout: VueGridLayout.GridLayout,
    GridItem: VueGridLayout.GridItem,
    BaseTable,
    DiagnosisSpecialAdvice,
    DiagnosisTechAdvice,
    VueQr,
    Discussion,
  },
  props: {
    diagnosis: {
      type: Object,
      default: diagnosisDefault,
    },
  },
  data() {
    return {
      prevPathologyId: this.diagnosis.previousPathologyId,
      nextPathologyId: this.diagnosis.nextPathologyId,
      userId: this.$store.state.user.id,
      shareName: this.$store.state.user.name,
      shareDialogVisible: false,
      logoSrc: '',
      appSrc: '', //二维码包含的url字符串
      diagnosisTemplateData: [],
      filterText: '',
      AnnotationsServiceURL: process.env.pathologyServiceURL,
      selectedList: [], // 多选 全选 数据
      teachingLibrarySelectedList: [],
      scienceLibrarySelectedList: [],
      activeDoctorId: 0,
      isInvited: false,
      // 当前展示的诊断医生级别
      activeLevel: 0,

      imageServiceURL: process.env.ImageServiceURL,
      doctorAdviceMap: doctorAdviceMapBase,
      userLevel: userLevelBase,
      diagnosisTemplateVisible: true,
      layoutTemplateCol: 5,
      isShowLayoutAiInfo: false,
      isCollected: false,
      layoutAiInfoCol: 2,
      // layoutTemplate 相关
      diagnosisTemplateTabActive: 'myTemplate',

      isDiagnosisTemplateReady: false,
      diagnosisTemplateFilterKey: '',
      diagnosisTemplateList: [],
      diagnosisTemplateProps: {
        children: 'children',
        label: 'nodeName',
        isLeaf: 'isLeaf',
      },
      diagnosisExpandList: [],
      // layoutMain 相关
      isShowDeadline: false,

      searchPathologyId: '',

      // 加做项目数据
      // specialAdviceCount: 0,
      // techAdviceCount: 0,
      specialExtraProjectList: [],
      techExtraProjectList: [],

      qualityForm: {
        frozenCoincidenceRate: '',
        diagnosticAccordanceRate: '',
        diagnosticCarefulnessRate: '',
        biopsyQuality: '',
        scanQuality: '',
      },

      dictionaryMap: [
        {
          code: 'coincidenceRate',
          array: 'frozenCoincidenceRateList',
        },
        {
          code: 'coincidenceRate',
          array: 'diagnosticAccordanceRateList',
        },
        {
          code: 'careful',
          array: 'DiagnosticCarefulnessRateList',
        },
        {
          code: 'sliceQuality',
          array: 'biopsyQualityList',
        },
        {
          code: 'scanningQuality',
          array: 'scanQualityList',
        },
      ],
      frozenCoincidenceRateList: [],
      diagnosticAccordanceRateList: [],
      DiagnosticCarefulnessRateList: [],
      biopsyQualityList: [],
      scanQualityList: [],

      checkCategorySelected: '',
      checkCategoryList: [],
      opinionTabActiveLevel: '',
      opinionTabActive: '',
      opinionTabList: [],

      annotationsList: [],

      // 基础信息字段列表
      baseInfoList: [
        {
          
          value: '',
          key: 'name',
          label: '姓名：',
        },
        {
          
          value: '',
          key: 'sexName',
          label: '性别：',
        },
        {
          
          value: '',
          key: 'ageAll',
          label: '年龄：',
        },
        {
          
          value: '',
          key: 'cardId',
          label: '身份证号：',
        },
        {
          
          value: '',
          key: 'branchName',
          label: '分院名称：',
        },
        {
          
          value: '',
          key: 'sendDoctor',
          label: '送检医生：',
        },
        {
          
          value: '',
          key: 'sendDepartment',
          label: '送检科室：',
        },
        {
          
          value: '',
          key: 'wardName',
          label: '病区名称：',
        },
        {
          
          value: '',
          key: 'bedId',
          label: '床位号：',
        },
        {
          
          value: '',
          key: 'specimenName',
          label: '标本名称：',
        },
        {
          
          value: '',
          key: 'specimenTypeName',
          label: '标本类型：',
        },
        {
          
          value: '',
          key: 'specimenRegisterTime',
          label: '标本登记时间：',
        },
      ],
      // 模板初始化完成确认
      reportTemplateReady: false,
      // 意见数据表单
      detailForm: {},
      // 意见数据缓存
      detailCache: {},
      // 模板组件列表
      componentList: [],
      reportTemplateCol: 12,

      submitDialog: {
        title: '',
        visible: false,
        isReady: false,
      },
      submitTable: {
        data: [],
        header: [
          {
            label: '姓名',
            prop: 'name',
            width: '120',
          },
          {
            label: '医生职称',
            prop: 'medicalTitleName',
            width: '160',
          },
          {
            label: '诊断权限',
            prop: 'nextFlowLevelLabel',
            width: '100',
          },
          {
            label: '联系电话',
            prop: 'phone',
            width: '140',
          },
          {
            label: '擅长',
            prop: 'speciality',
          },
        ],
        operation: [
          {
            label: '提交',
            functionKey: 'submitTableSubmitConfirm',
            key: 'A',
          },
        ],
        pageInfo: {
          page: 1,
          size: 15,
          total: 0,
        },
      },
      specialAdviceDialog: {
        title: '特殊医嘱',
        visible: false,
      },
      techAdviceDialog: {
        title: '技术医嘱',
        visible: false,
      },
      // 下方标签页数据
      ReportData: [],
      selectionItemsvalue: [],
      selectionItemsFilter: {},
      activeName1: 'first',
      reportActiveName: 'tezheng',
      inspectionloading: false,
      ifShowMain: true,
      picLoading: false,
      // 趋势图弹窗
      PICdialogVisible: false,
      PicSelectionItemsData: [],
      SelectionItemsData: [],
      picForm: {},
      doctorsTable: {
        selected: true,
        isReady: false,
        data: [],
        header: [
          {
            label: '姓名',
            prop: 'name',
            width: '80',
          },
          {
            label: '医生职称',
            prop: 'positionName',
            width: '150',
          },
          {
            label: '医生职级',
            prop: 'medicalTitleName',
            width: '150',
          },
          {
            label: '所属医院',
            prop: 'institutionName',
          },
          {
            label: '医生擅长',
            prop: 'major',
          },
        ],
        operation: [
          {
            label: '邀请',
            functionKey: 'doctorsTableAssign',
          },
        ],
        pageInfo: {
          page: 1,
          size: 15,
          total: 0,
        },
      },
      scienceLibraryTable: {
        selected: true,
        isReady: false,
        data: [],
        header: [
          {
            label: '科研库编号',
            prop: 'researchLibrariesNumber',
          },
          {
            label: '科研库名称',
            prop: 'researchLibrariesName',
          },
          {
            label: '科研负责人',
            isRender: true,
            render: (h, params) => {
              let usersName = '';
              if (params.row.users) {
                params.row.users.forEach((item) => {
                  if (item.name == null) {
                  } else {
                    usersName = usersName + item.name + ' ';
                  }
                });
              }
              return h('span', usersName);
            },
          },
          {
            label: '创建时间',
            prop: 'createTime',
          },
          {
            label: '结束时间',
            prop: 'researchLibrariesEndTime',
          },
          {
            label: '备注',
            prop: 'researchLibrariesRemark',
          },
        ],
        operation: [],
        pageInfo: {
          page: 1,
          size: 15,
          total: 0,
        },
      },
      teachingLibraryTable: {
        selected: true,
        isReady: false,
        data: [],
        header: [
          {
            label: '教学库编号',
            prop: 'teachingLibrariesNumber',
          },
          {
            label: '教学库名称',
            prop: 'teachingLibrariesName',
          },
          {
            label: '教学负责人',
            isRender: true,
            render: (h, params) => {
              let usersName = '';
              if (params.row.users) {
                params.row.users.forEach((item) => {
                  if (item.name == null) {
                  } else {
                    usersName = usersName + item.name + ' ';
                  }
                });
              }
              return h('span', usersName);
            },
          },

          {
            label: '创建时间',
            prop: 'createTime',
          },
          {
            label: '结束时间',
            prop: 'teachingLibrariesEndTime',
          },

          {
            label: '备注',
            prop: 'teachingLibrariesRemark',
          },
        ],
        operation: [],
        pageInfo: {
          page: 1,
          size: 15,
          total: 0,
        },
      },
      doctorsDialog: {
        visible: false,
      },
      scienceLibraryDialog: {
        visible: false,
      },
      teachingLibraryDialog: {
        visible: false,
      },
      AIEvaluationForm: {
        chronicInflammationAi: '', //慢性炎症
        imAi: '', //肠化
        atrophyAi: '', //萎缩
        activityAi: '', //活动度
        hpai: '', //HP
        alienGrowthAi: '', //异性增生
      },
      predStatus: 'true',
      beClickedDoctor: '', //被点击的医生名字
      isSuccessSubmitReportResult: '', //琅珈回写的状态文本
      tumorReport: false,//杨中心肿瘤请报告
    };
  },

  async mounted() {
   
    this.diagnosis.cardId = this.diagnosis.cardId;
    this.isCollected = !!this.diagnosis.collectionId;
    console.log('this diagnosis111111', this.diagnosis);
    // 诊断模板获取
    // this.diagnosisTemplateRequest();
    this.otherDiagnosisTemplateRequest();
    // 设置病理编号搜索框初始值
    this.searchPathologyId = this.diagnosisPathologyId;
    //检查类型获取
    this.getCheckCategoryList();
    // 字典数据获取
    this.dictionariesRequest(this.dictionaryMap);
    // 当前标签页显示确认
    this.opinionTabActiveLevel += this.isFinished
      ? this.diagnosisPrevLevel
      : this.diagnosisLevel;
    // this.opinionTabActive += this.diagnosis.diagnosisDetailList.find(
    //     (item) =>
    //         item.currentLevel == this.opinionTabActiveLevel &&
    //         item.diagnosisType == 0
    // ).id;
    this.opinionTabActive += this.diagnosis.diagnosisDetailList.find(
      (item) => this.userId == item.doctorId
    ).id;
    //质控数据回显
    if (this.diagnosis.diagnosisDetailList.length > 0) {
      const { state } = this.$store;
      const _this = this;
      this.diagnosis.diagnosisDetailList.forEach((item) => {
        if (item.doctorId === state.user.id) {
          _this.qualityForm.frozenCoincidenceRate = item.frozenCoincidenceRate;
          _this.qualityForm.diagnosticAccordanceRate =
            item.diagnosticAccordanceRate;
          _this.qualityForm.diagnosticCarefulnessRate =
            item.diagnosticCarefulnessRate;
          _this.qualityForm.biopsyQuality = item.biopsyQuality;
          _this.qualityForm.scanQuality = item.scanQuality;
        }
      });
    }

    console.log('this.qualityForm', this.qualityForm);
    // 从诊断详情获取用户列表，再请求用户数据
    // 生成诊断医生列表
    /* eslint no-await-in-loop:0 */
    this.opinionTabList = [];
    for (let i = 0; i < this.diagnosis.diagnosisDetailList.length; i++) {
      const t = this.diagnosis.diagnosisDetailList[i];
      const levelItem = this.userLevel.find(
        (item) => item.level === t.currentLevel
      );
      if (t.diagnosisType == 1) {
        levelItem.tabLabel = `邀请(${t.doctorName})`;
      } else {
        levelItem.tabLabel = `${levelItem.label}(${t.doctorName})`;
      }
      levelItem.name = t.id;
      this.opinionTabList.push(JSON.parse(JSON.stringify(levelItem)));
    }

    // 基本信息格式化
    this.baseInfoList.forEach((info, index) => {
      this.baseInfoList[index].value = _.get(this.diagnosis, info.key, '');
    });
    this.checkCategorySelected = this.diagnosis.checkCategory;
    this.reportTemplateRequest();
    this.extraProjectRequest();
    //一个诊断会有多张切片，一个切片对应一个ai，如果有多张默认取第一张切片ai

    if (this.diagnosis.biopsyList.length > 0) {
      this.diagnosis.biopsyList.forEach((item) => {
        this.getAiEvaluation(item.id);
      });
    }
  },
  computed: {
    diagnosisStomachSample() {
      if (this.diagnosis.stomachSample == "") {
        return false
      } else {
        return true
      }
    },
    reportResultTextShow() {
      if (!!this.isSuccessSubmitReportResult) {
        return true;
      } else {
        return false;
      }
    },
    isSuccessSubmitReportStatus() {
      return this.diagnosis.diagnosisDetailList.find(
        (t) => t.doctorId === this.userId
      ).isSuccessSubmitReport;
    },
    diagnosisCheckCategoryName() {
      return this.diagnosis.checkCategoryName;
    },
    layoutMainCol() {
      const layoutTemplateCol = this.diagnosisTemplateVisible
        ? this.layoutTemplateCol
        : 0;
      const layoutAiInfoCol = this.isShowLayoutAiInfo
        ? this.layoutAiInfoCol
        : 0;
      return 24 - layoutTemplateCol - layoutAiInfoCol;
    },
    diagnosisTemplatesType() {
      return this.isShowInstitutionTemplates ? 0 : 1;
    },
    isShowInstitutionTemplates() {
      return this.diagnosisTemplateTabActive === 'orgTemplate';
    },
    tagDeadlineType() {
      return 'danger';
    },
    specialExtraCount() {
      return this.specialExtraProjectList.length;
    },
    techExtraCount() {
      return this.techExtraProjectList.length;
    },
    collectionTagType() {
      return this.isCollected ? 'success' : 'danger';
    },
    finishType() {
      return this.isFinished ? 'success' : 'danger';
    },
    canAddExtraProject() {
      return this.isTheseDoctor;
    },
    levelLabel() {
      return _.get(this.diagnosis, 'currentLevelLabel', '');
    },

    subgroupId() {
      return _.get(this.diagnosis, 'subgroupId', 0);
    },
    diagnosisId() {
      return _.get(this.diagnosis, 'id', 0);
    },
    diagnosisPathologyId() {
      return _.get(this.diagnosis, 'pathologyId', '');
    },
    diagnosisLevel() {
      return _.get(this.diagnosis, 'currentLevel', 0);
    },
    diagnosisPrevLevel() {
      return _.get(this.diagnosis, 'prevLevel', 0);
    },
    isNeedFinalVerify() {
      return this.diagnosis.canFinalVerify;
    },
    isAssigned() {
      return this.diagnosisLevel !== 1;
    },
    isFinished() {
      return this.diagnosisLevel === 6;
    },
    isFirstOpinion() {
      return this.diagnosisPrevLevel === 1;
    },
    isThisDoctor() {
      const { state } = this.$store;
      if (this.isInvited) {
        return state.user.id === this.activeDoctorId;
      } else {
        const level = this.isFinished
          ? this.diagnosisPrevLevel
          : this.diagnosisLevel;
        const detail = this.detailGetByLevel(level);
        return detail ? state.user.id === detail.doctorId : false;
      }
    },
    isTheseDoctor() {
      return this.diagnosis.diagnosisDetailList.some(
        (t) => t.doctorId === this.userId
      );
    },
    isTheseDoctorInfo() {
      return this.diagnosis.diagnosisDetailList.find(
        (t) => t.doctorId === this.userId
      );
    },
    isThisOpinionTab() {
      return this.diagnosis.diagnosisDetailList.find(
        (t) => t.doctorId === this.userId
      ).id === Number(this.opinionTabActive)
        ? true
        : false;
    },
    submitButtonVisible() {
      return this.diagnosisLevel === 2 || this.diagnosisLevel === 3;
    },
    issueButtonVisible() {
      return this.diagnosisLevel === 3;
    },
    auditButtonVisible() {
      return this.diagnosisLevel === 4;
    },
    finalVerifyButtonVisible() {
      return this.diagnosisLevel === 5;
    },
    finishLabel() {
      switch (this.diagnosisLevel) {
        case 3:
          return '核发';
        case 4:
          return '审核';
        case 5:
          return '终审';
        default:
          return '';
      }
    },
    extraProjectPermission() {
      // 其他用户只能查看加做
      if (!this.isTheseDoctor) {
        return 0;
      }

      const firstVisitDetail = this.detailGetByLevel(2);
      if (firstVisitDetail) {
        const { state } = this.$store;
        const uid = state.user.id;

        //邀请医生的权限控制
        const inviteDoctor = this.diagnosis.diagnosisDetailList.find((item) => {
          return item.doctorId === uid;
        });

        // 初诊医生只能申请加做  邀请医生
        if (
          firstVisitDetail.doctorId === uid ||
          inviteDoctor.diagnosisType === 1
        ) {
          return 1;
        }
        // 核发/审核/终审医生可以申请并批准加做
        return 2;
      }
      return 2;
    },
    //该医生是否有科内会诊申请权限
    isDivisionConsultationApplyPermissions() {
      return _.get(
        this.$store.state,
        'user.isDivisionConsultationApplyPermissions',
        false
      );
    },
    //该医生是否有院外会诊申请权限
    isOutsideConsultationApplyPermissions() {
      return _.get(
        this.$store.state,
        'user.isOutsideConsultationApplyPermissions',
        false
      );
    },
    // prevPathologyId() {
    //     return _.get(this.diagnosis, 'previousPathologyId', '');
    // },
    // nextPathologyId() {
    //     return _.get(this.diagnosis, 'nextPathologyId', '');
    // },
  },
  updated() {
    console.log(this.$refs);
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    },
    'diagnosis.previousPathologyId': {
      handler(newName, oldName) {
        if (localStorage.getItem('submitAfterSaveBeforeStatus') == 'true') {
          this.prevPathologyId = localStorage.prevPathologyId;
        } else {
          this.prevPathologyId = newName;
        }
      },
      immediate: true,
    },
    'diagnosis.nextPathologyId': {
      handler(newName, oldName) {
        if (localStorage.getItem('submitAfterSaveBeforeStatus') == 'true') {
          this.nextPathologyId = localStorage.nextPathologyId;
          localStorage.removeItem('submitAfterSaveBeforeStatus');
        } else {
          this.nextPathologyId = newName;
        }
      },
      immediate: true,
    },
  },
  methods: {
    btnTumorReport() {
      this.tumorReport = true
    },
    shareQRCode() {
      this.shareDialogVisible = true;
      // this.appSrc = `http://www.aikeji.top:30001/share/index/${this.diagnosis.diagnosisUuid}`;
      this.appSrc = `192.168.1.38:3001/share/index/${this.diagnosis.diagnosisUuid}`;
      console.log('this.appSrc',this.appSrc)
    },
    //一个诊断会有多张切片，一个切片对应一个ai，如果有多张默认取第一张切片ai
    getAiEvaluation(biopsyId) {
      let _this = this;
      _this
        .$axios({
          method: 'GET',
          url: `${_this.AnnotationsServiceURL}/annotations/results/aiprediction/${biopsyId}`,
        })
        .then((res) => {
          if (res.data.code === 200) {
            if (res.data.data.info.pred === 0) {
              this.predStatus = 'false';
              res.data.data.info.resultLevel.forEach((item) => {
                if (item.key === '肠化') {
                  _this.AIEvaluationForm.imAi = item.value;
                }
                if (item.key === '萎缩') {
                  _this.AIEvaluationForm.atrophyAi = item.value;
                }
                if (item.key === '活动性') {
                  _this.AIEvaluationForm.activityAi = item.value;
                }
                if (item.key === '慢性炎症') {
                  _this.AIEvaluationForm.chronicInflammationAi = item.value;
                }
                if (item.key === 'HP') {
                  _this.AIEvaluationForm.hpai = item.value;
                }
                if (item.key === '异性增生') {
                  _this.AIEvaluationForm.alienGrowthAi = item.value;
                }
              });
            }
          }
        });
    },
    //点击属性自动赋值AI
    aiValueToAssign(name) {
      if (this.predStatus === 'true') {
        this.$message({
          type: 'info',
          message: '还没有AI阴性分析结果',
        });
      } else {
        let AIData = [
          this.AIEvaluationForm.chronicInflammationAi,
          this.AIEvaluationForm.activityAi,
          this.AIEvaluationForm.atrophyAi,
          this.AIEvaluationForm.imAi,
          this.AIEvaluationForm.alienGrowthAi,
          this.AIEvaluationForm.hpai,
        ];
        if (name === '胃窦输入值') {
          for (let i = 0; i < 6; i++) {
            this.$set(
              this.detailForm,
              `selection_table_${i + 1}1`,
              AIData[i]
            );
            // this.detailForm[`selection_table_${i + 1}1`] = AIData[i];
          }
        } else if (name === '胃角输入值') {
          for (let i = 0; i < 6; i++) {
            this.$set(
              this.detailForm,
              `selection_table_${i + 1}2`,
              AIData[i]
            );
            // this.detailForm[`selection_table_${i + 1}2`] = AIData[i];
          }
        } else if (name === '胃体输入值') {
          for (let i = 0; i < 6; i++) {
            this.$set(
              this.detailForm,
              `selection_table_${i + 1}3`,
              AIData[i]
            );
            // this.detailForm[`selection_table_${i + 1}3`] = AIData[i];
          }
        } else if (name === '贲门输入值') {
          for (let i = 0; i < 6; i++) {
            this.$set(
              this.detailForm,
              `selection_table_${i + 1}4`,
              AIData[i]
            );
            // this.detailForm[`selection_table_${i + 1}4`] = AIData[i];
          }
        } else if (name === '胃底输入值') {
          for (let i = 0; i < 6; i++) {
            this.$set(
              this.detailForm,
              `selection_table_${i + 1}5`,
              AIData[i]
            );
            // this.detailForm[`selection_table_${i + 1}5`] = AIData[i];
          }
        } else if (name === '额外采集部位1输入') {
          for (let i = 0; i < 6; i++) {
            this.$set(
              this.detailForm,
              `selection_table_${i + 1}6`,
              AIData[i]
            );
            // this.detailForm[`selection_table_${i + 1}5`] = AIData[i];
          }
        }
        this.$message({
          type: 'success',
          message: 'AI赋值成功',
        });
        // this.$confirm(`确定进行AI分析赋值?`, '提示', {
        //   confirmButtonText: '确定',
        //   cancelButtonText: '取消',
        //   type: 'warning',
        // })
        //   .then(() => {
        //     

        //   })
        //   .catch(() => {
        //     this.$message({
        //       type: 'info',
        //       message: '已取消',
        //     });
        //   });
      }
    },

    filterNode(value, data) {
      if (!value) return true;
      return data.nodeName.indexOf(value) !== -1;
    },
    handleClick() {
      console.log('handleClick');
    },
    diagnosisRefresh() {
      this.$emit('diagnosisRequest');
    },
    diagnosisTemplateVisibleChange() {
      this.diagnosisTemplateVisible = !this.diagnosisTemplateVisible;
      this.diagnosisTemplateRequest();
    },
    // 诊断模板 - 标签页点击
    diagnosisTemplateTabChange() {
      //this.diagnosisTemplateRequest();
      this.otherDiagnosisTemplateRequest();
    },
    // 诊断模板 - 获取诊断模板
    async otherDiagnosisTemplateRequest() {
      this.isDiagnosisTemplateReady = false;
      const res = await this.$axios({
        method: 'GET',
        url: `/PROXY-Remote/diagnose-templates/getDiagnoseTemplate/byIsPersonal/${this.diagnosisTemplatesType}`,
      });

      if (res && res.data.code === 200) {
        this.diagnosisTemplateData = res.data.data;
      } else {
        this.$message.info('请求失败');
      }

      this.isDiagnosisTemplateReady = true;
    },
    // 诊断模板 - 获取诊断模板
    async diagnosisTemplateRequest() {
      this.isDiagnosisTemplateReady = false;
      const param = {
        type: this.diagnosisTemplatesType,
        key: this.diagnosisTemplateFilterKey,
      };

      const res = await this.$axios({
        method: 'get',
        url: '/PROXY-Remote/diagnose-templates',
        params: param,
      });

      if (res && res.data.code === 200) {
        this.diagnosisTemplateList = [];
        res.data.data.forEach((e) => {
          this.diagnosisTemplateList.push({
            id: e.id,
            nodeName: e.nodeName,
            isLeaf: e.isLeaf,
            children: [],
          });
        });
      } else {
        this.$message.info('请求失败');
      }

      this.isDiagnosisTemplateReady = true;
    },
    async diagnosisTemplateFilter() {
      if (this.diagnosisTemplateFilterKey === '') {
        this.diagnosisTemplateRequest();
        return;
      }

      this.isDiagnosisTemplateReady = false;
      const param = {
        type: this.diagnosisTemplatesType,
        key: this.diagnosisTemplateFilterKey,
      };

      const res = await this.$axios({
        method: 'get',
        url: '/PROXY-Remote/diagnose-templates',
        params: param,
      });

      if (res && res.data.code === 200) {
        // 确定默认展开节点
        this.diagnosisExpandList = [];

        const firstNode = res.data.data[0];
        this.diagnosisExpandList.push(firstNode.id);
        if (_.get(firstNode, 'children.length', 0)) {
          const secondNode = firstNode.children[0];
          this.diagnosisExpandList.push(secondNode.id);
          if (_.get(secondNode, 'children.length', 0)) {
            const thirdNode = secondNode.children[0];
            this.diagnosisExpandList.push(thirdNode.id);
          }
        }

        // 确定树的数据
        this.diagnosisTemplateList = [];
        res.data.data.forEach((e) => {
          this.diagnosisTemplateList.push(e);
        });
        this.isDiagnosisTemplateReady = true;
      } else {
        this.$message.info('请求失败');
        this.isDiagnosisTemplateReady = true;
      }
    },
    // 诊断模板 - 节点加载
    async diagnosisTemplateLoad(node, resolve) {
      // 无效 id
      if (!node.data.id) {
        resolve([]);
      } else if (this.diagnosisTemplateFilterKey === '') {
        const res = await this.$axios({
          method: 'GET',
          url: `/PROXY-Remote/diagnose-templates/${node.data.id}`,
        });
        if (res && res.data.code === 200) {
          resolve(res.data.data);
        }
      } else {
        // 叶子节点
        if (node.level >= 3) resolve([]);
        if (node.data.parentId === 0) {
          // 根节点 - 展开
          this.diagnosisTemplateList.forEach((rootNode) => {
            if (rootNode.id === node.data.id) {
              const results = rootNode.children;
              resolve(results);
            }
          });
        } else {
          // 中间节点 - 展开
          this.diagnosisTemplateList.forEach((rootNode) => {
            if (rootNode.children) {
              rootNode.children.forEach((secondLevel) => {
                if (secondLevel.id === node.data.id) {
                  const results = secondLevel.children;
                  resolve(results);
                }
              });
            }
          });
        }
      }
    },
    // 诊断模板 - 节点点击
    diagnosisTemplateNodeClick(data, node) {
      if (this.isThisOpinionTab && data.isLeaf) {
        let flag = false;
        let item = false;
        let i = '';
        // 镜下所见
        i = 'input_normal_microFingings';
        item = this.componentList.some((t) => t.i === i);
        if (item) {
          if (this.detailForm[i]) {
            this.$set(
              this.detailForm,
              'input_normal_microFingings',
              this.detailForm[i] + '\n' + node.data.diagnoseLook
            );
          } else {
            this.$set(
              this.detailForm,
              'input_normal_microFingings',
              node.data.diagnoseLook
            );
          }
          flag = true;
        }
        // 病理诊断
        i = 'input_normal_diagnose';
        item = this.componentList.some((t) => t.i === i);
        if (item) {
          if (this.detailForm[i]) {
            //this.detailForm[i] += '\n' + node.data.diagnoseLook;
            this.$set(
              this.detailForm,
              'input_normal_diagnose',
              this.detailForm[i] + '\n' + node.data.diagnoseLook
            );
          } else {
            //this.detailForm[i] = node.data.diagnoseLook;
            this.$set(
              this.detailForm,
              'input_normal_diagnose',
              node.data.diagnoseLook
            );
          }
          flag = true;
        }
        //组织学诊断
        i = 'input_organ_diagnose';
        item = this.componentList.some((t) => t.i === i);
        if (item) {
          if (this.detailForm[i]) {
            this.$set(
              this.detailForm,
              'input_organ_diagnose',
              this.detailForm[i] + '\n' + node.data.diagnoseLook
            );
          } else {
            this.$set(
              this.detailForm,
              'input_organ_diagnose',
              node.data.diagnoseLook
            );
          }
          flag = true;
        }
        if (!flag) {
          this.$message.warning('当前报告不可使用模板');
        }
      }
    },
    // 诊断模板 - 节点复制
    async diagnosisTemplateNodeCopy(node) {
      const res = await this.$axios({
        method: 'post',
        url: `/PROXY-Remote/diagnose-templates/copy?id=${node.data.id}`,
      });

      if (res && res.data.code === 200) {
        this.$message.success('复制成功');
      } else if (res.data.code === 403) {
        this.$message.warning('我的模板中包含相同名称的数据，修改后才能复制');
      } else {
        this.$message.warning('复制失败');
      }
    },
    async getCheckCategoryList() {
      const res = await this.$axios({
        method: 'GET',
        url: '/PROXY-Remote/dicts/by-code',
        params: {
          code: 'checkCategory',
        },
      });
      if (res && res.data.code === 200) {
        const result = res.data.data;
        this.checkCategoryList = result;
      }
    },
    dictionariesRequest(dictMap) {
      // 字典数据请求
      dictMap.forEach(async (map) => {
        const res = await this.$axios({
          method: 'GET',
          url: '/PROXY-Remote/dicts/list',
          params: {
            code: map.code,
            page: 0,
            size: 99,
          },
        });

        if (res && res.data.code === 200) {
          const result = res.data;
          result.data.forEach((t) => {
            this[map.array].push({
              id: t.id,
              label: t.name,
            });
          });
        }
      });
    },

    // 诊断 - 搜索
    diagnosisSearch() {
      if (this.searchPathologyId !== this.diagnosisPathologyId) {
        this.$emit('diagnosisSearch', this.searchPathologyId);
      }
    },
    // 诊断 - 上一个
    diagnosisLast() {
      this.$emit('diagnosisSearch', this.prevPathologyId);
    },
    // 诊断 - 下一个
    diagnosisNext() {
      this.$emit('diagnosisSearch', this.nextPathologyId);
    },
    // TODO 诊断 - 检验分析
    diagnosisCheckAnalysis() {
      console.log('diagnosisCheckAnalysis');
      this.$refs.bottom.changeShowMain();
    },
    // 加做项目
    specialExtraDialogOpen() {
      this.specialAdviceDialog.visible = true;
    },
    specialAdviceDialogClose() {
      this.specialAdviceDialog.visible = false;
      this.extraProjectRequest();
    },
    techExtraDialogOpen() {
      this.techAdviceDialog.visible = true;
    },
    techAdviceDialogClose() {
      this.techAdviceDialog.visible = false;
      this.extraProjectRequest();
    },
    // 收藏 - 改变
    async collectChange() {
      if (this.isCollected) {
        const res = await this.$axios({
          method: 'DELETE',
          url: `/PROXY-Remote/collections/${this.diagnosis.collectionId}`,
        });

        if (res && res.data.code === 200) {
          this.diagnosis.collectionId = null;
          this.$message.success('取消收藏成功');
          this.isCollected = false;
        } else {
          this.$message.warning('取消收藏失败');
        }
      } else {
        // this.$prompt('请输入收藏备注', '收藏备注', {
        //   confirmButtonText: '确定',
        //   cancelButtonText: '取消',
        //   inputPattern: /.*[^\s]/,
        //   inputErrorMessage: '收藏备注不能为空'
        // })
        //   .then(async ({ value }) => {
        //     const res = await this.$axios({
        //       method: 'POST',
        //       url: `/PROXY-Remote/collections/${this.diagnosisId}?remark=value`
        //     });

        //     if (res && res.data.code === 200) {
        //       this.diagnosis.collectionId = res.data.data.id;
        //       this.$message.success('收藏成功');
        //       this.isCollected = true;
        //     } else {
        //       this.$message.warning('收藏失败');
        //     }
        //   })
        //   .catch(() => {
        //     this.$message.info('取消操作');
        //   });
        this.onComment();
      }
    },
    onComment: function () {
      var _this = this;
      const h = _this.$createElement;
      _this
        .$msgbox({
          title: '收藏备注',
          message: h(
            'div',
            {
              attrs: {
                class: 'el-textarea',
              },
            },
            [
              h('textarea', {
                attrs: {
                  class: 'el-textarea__inner',
                  autocomplete: 'off',
                  rows: 4,
                  id: 'commentContent',
                },
                value: _this.commentContent,
                on: { input: _this.onCommentInputChange },
              }),
            ]
          ),
          showCancelButton: true,
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          beforeClose: async (action, instance, done) => {
            if (action === 'confirm') {
              instance.confirmButtonLoading = true;
              instance.confirmButtonText = '提交中...';
              const res = await this.$axios({
                method: 'POST',
                url: `/PROXY-Remote/collections/${this.diagnosisId}?remark=${_this.commentContent}`,
              });

              if (res && res.data.code === 200) {
                this.diagnosis.collectionId = res.data.data.id;
                this.$message.success('收藏成功');
                this.isCollected = true;
              } else {
                this.$message.warning('收藏失败');
              }
              done();
            } else {
              done();
            }
          },
        })
        .then((action) => { });
    },
    onCommentInputChange() {
      this.commentContent = document.getElementById('commentContent').value;
    },
    addTeachingLibrary() {
      this.teachingLibraryDialog.visible = true;
      this.teachingLibraryTableDataGet();
    },
    teachingLibraryTableDataGet() {
      this.teachingLibraryTable.data = [];
      this.$axios({
        method: 'GET',
        url: `/PROXY-Remote/TeachingLibraries/findDoctorTeachingLibraries/${this.teachingLibraryTable.pageInfo.size
          }/${this.teachingLibraryTable.pageInfo.page - 1}`,
      }).then((res) => {
        if (res.data.code === 200) {
          this.teachingLibraryTable.isReady = true;
          this.teachingLibraryTable.data = res.data.data;
          this.teachingLibraryTable.pageInfo = res.data.pageInfo;
          this.teachingLibraryTable.pageInfo.page = res.data.pageInfo.page + 1;
        } else {
          this.$message.info(res.data.message);
        }
      });
    },
    btnTeachingLibrary() {
      if (this.teachingLibrarySelectedList.length > 0) {
        const tIds = this.teachingLibrarySelectedList.map((item) => {
          return item.id;
        });
        this.$axios({
          method: 'POST',
          url: `/PROXY-Remote/TeachingLibraries/saveDiagnosisBiopsies/${this.diagnosisId}`,
          data: JSON.stringify(tIds),
        }).then((res) => {
          if (res.data.code === 200) {
            this.$message.success(res.data.message);
          } else {
            this.$message.info(res.data.message);
          }
        });
      } else {
        this.$message.warning('请先选择教学库');
      }
    },
    teachingLibrarySelectionChange(selection) {
      this.teachingLibrarySelectedList = selection;
    },
    teachingLibraryHandleSelectAll(row) {
      this.teachingLibrarySelectedList = row;
    },
    btnScienceLibrary() {
      if (this.scienceLibrarySelectedList.length > 0) {
        const tIds = this.scienceLibrarySelectedList.map((item) => {
          return item.id;
        });
        this.$axios({
          method: 'POST',
          url: `/PROXY-Remote/biopsyResearchLibraries/saveDiagnosisBiopsies/${this.diagnosisId}`,
          data: JSON.stringify(tIds),
        }).then((res) => {
          if (res.data.code === 200) {
            this.scienceLibraryDialog.visible = false;
            this.$message.success(res.data.message);
          } else {
            this.$message.info(res.data.message);
          }
        });
      } else {
        this.$message.warning('请先选择科研库');
      }
    },
    scienceLibrarySelectionChange(selection) {
      this.scienceLibrarySelectedList = selection;
    },
    scienceLibraryHandleSelectAll(row) {
      this.scienceLibrarySelectedList = row;
    },
    addScienceLibrary() {
      this.scienceLibraryTableDataGet();
    },
    scienceLibraryTableDataGet() {
      this.scienceLibraryTable.data = [];
      this.$axios({
        method: 'GET',
        url: `/PROXY-Remote/biopsyResearchLibraries/findDoctorResearchLibraries/${this.scienceLibraryTable.pageInfo.size
          }/${this.scienceLibraryTable.pageInfo.page - 1}`,
      }).then((res) => {
        if (res.data.code === 200) {
          this.scienceLibraryDialog.visible = true;
          this.scienceLibraryTable.isReady = true;
          this.scienceLibraryTable.data = res.data.data;
          this.scienceLibraryTable.pageInfo = res.data.pageInfo;
          this.scienceLibraryTable.pageInfo.page = res.data.pageInfo.page + 1;
        } else {
          this.$message.info(res.data.message);
        }
      });
    },
    // 报告 - 查看
    reportView() {
      const width = window.screen.availWidth + 10;
      const height = window.screen.availHeight + 10;
      window.open(
        `/detail/preview/${this.userId}/${this.diagnosisPathologyId}`,
        '_blank',
        `location=no,width=${width},height=${height}`
      );
    },
    // 报告 - 回收
    reportCallBack() {
      if (this.isSuccessSubmitReportStatus === 2) {
        this.$prompt('请输入回收说明', '回收说明', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputPattern: /.*[^\s]/,
          inputErrorMessage: '回收说明不能为空',
        })
          .then(async ({ value }) => {
            const res = await this.$axios({
              method: 'PUT',
              url: `/PROXY-Remote/diagnosis/${this.diagnosisId}/send-back`,
              params: {
                remark: value,
              },
            });
            if (res && res.data.code === 200) {
              this.$message.success('回收成功');
              this.diagnosisRefresh();
            } else {
              this.$message.warning('回收失败');
            }
          })
          .catch(() => {
            this.$message.info('取消操作');
          });
      } else {
        this.$message.info('已经回写成功,不可取消');
      }
    },
    // TODO 报告 - 延期
    reportDelay() {
      console.log('reportDelay');
    },
    // 诊断 - 保存
    async diagnosisSave() {
      const diagnosisType = sessionStorage.getItem('diagnosisType'); //被邀请的医生diagnosisType==1点击暂存或者复制其他医生诊断意见加上此参数
      const detailString = JSON.stringify(this.detailForm);
      const { state } = this.$store;
      const res = await this.$axios({
        url: `/PROXY-Remote/diagnosis/${this.diagnosisId}/next-flow`,
        method: 'PUT',
        data: {
          isTempStorage: 1,
          doctorId: state.user.id,
          detailString,
          frozenCoincidenceRate: this.qualityForm.frozenCoincidenceRate,
          diagnosticAccordanceRate: this.qualityForm.diagnosticAccordanceRate,
          diagnosticCarefulnessRate: this.qualityForm.diagnosticCarefulnessRate,
          biopsyQuality: this.qualityForm.biopsyQuality,
          scanQuality: this.qualityForm.scanQuality,
          diagnosisType: diagnosisType,
        },
      });

      if (res && res.data.code === 200) {
        this.diagnosisRefresh();
        this.$message.success('保存成功');
      } else {
        this.$message.error('保存失败');
      }
    },
    // 诊断 - 提交
    diagnosisCommit() {
      this.submitDialogOpen(this.diagnosisLevel, false);
    },
    //初诊修改提交
    async diagnosisCommitUpdate() {
      let _this = this;
      const { state } = this.$store;
      const detailString = JSON.stringify(this.detailForm);
      this.diagnosis.diagnosisDetailList[0].detailString = detailString;
      const res = await this.$axios({
        url: `/PROXY-Remote/diagnosis-detail/updateDiagnosisDetail`,
        method: 'POST',
        data: this.diagnosis.diagnosisDetailList[0],
      });

      if (res && res.data.code === 200) {
        this.$message.success(`修改提交成功`);
        this.$store.commit('setPropertyGeneral', {
          key: 'diagnosis',
          value: {
            id: state.diagnosis.id,
            pathologyId: state.diagnosis.pathologyId,
            pDiagnosisType: state.diagnosis.pDiagnosisType,
          },
        });
        this.diagnosisRefresh();
        this.submitDialog.visible = false;
      } else {
        this.$message.error(res.data.message);
      }
    },
    // 诊断 - 核发
    diagnosisIssue() {
      this.diagnosisFinishRequest();

      // if (this.isNeedFinalVerify) {
      //     this.submitDialogOpen(this.diagnosisLevel, true);
      // } else {
      //     this.diagnosisFinishRequest();
      // }
    },
    // 诊断 - 审核
    diagnosisAudit() {
      this.diagnosisFinishRequest();
      //if (this.isNeedFinalVerify) {
      //    this.submitDialogOpen(this.diagnosisLevel, true);
      //} else {
      //    this.diagnosisFinishRequest();
      //}
    },
    // 诊断 - 终审
    diagnosisFinalVerify() {
      this.diagnosisFinishRequest();
    },
    // 诊断 - 请求结束诊断 (核发/审核/终审)
    async diagnosisFinishRequest() {
      const detailString = JSON.stringify(this.detailForm);

      await this.$axios({
        url: `/PROXY-Remote/diagnosis/${this.diagnosisId}/next-flow`,
        method: 'PUT',
        data: {
          isTempStorage: 0,
          detailString,
          level: 6,
          frozenCoincidenceRate: this.qualityForm.frozenCoincidenceRate,
          diagnosticAccordanceRate: this.qualityForm.diagnosticAccordanceRate,
          diagnosticCarefulnessRate: this.qualityForm.diagnosticCarefulnessRate,
          biopsyQuality: this.qualityForm.biopsyQuality,
          scanQuality: this.qualityForm.scanQuality,
          tumorReport: this.tumorReport,
        },
      }).then((res) => {
        // 请求失败
        if (res.data.code === 409) {
          this.$message.error(res.data.message);
          // this.$message.error(`${this.finishLabel}失败`);
          throw new Error(res.data);
        } else if (res.data.code === 200) {
          // 请求成功
          this.$message.success(`${this.finishLabel}成功`);
          this.diagnosisRefresh();
        }
      });
    },
    // // TODO 诊断 - 讨论
    diagnosisDiscussion(val) {
      this.$confirm(
        '所有科内医生都会看到此病人数据进行科内会诊,确定吗?如果是想让某个科内医生看您可以使用邀请功能.',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }
      )
        .then(async () => {
          await this.askConsulation(val);
        })
        .catch(() => { });
    },
    // TODO 诊断 - 转院外
    diagnosisSendOut(val) {
      this.askConsulation(val);
    },
    askConsulation(val) {
      this.$axios({
        method: 'POST',
        url: `/PROXY-Remote/diagnosis/updateDiagnosis/for/consultationApplyPermissions`,
        data: {
          judgeDivisionOrOutside: val, //该参数如果传0时，代表科内，传1时，代表院外
          diagnosisId: this.diagnosisId, //诊断ID
        },
      }).then((res) => {
        if (res && res.data.code === 409) {
          this.$message.info(res.data.message);
        } else if (res && res.data.code === 200) {
          this.$message.success(res.data.message);
        } else {
          this.$message.warning(res.data.message);
        }
      });
    },
    // 诊断 - 退回
    diagnosisSendBack() {
      this.$prompt('请输入退回说明', '退回说明', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /.*[^\s]/,
        inputErrorMessage: '退回说明不能为空',
      })
        .then(async ({ value }) => {
          const res = await this.$axios({
            // 详见 axios 请求配置项
            method: 'PUT',
            url: `/PROXY-Remote/diagnosis/${this.diagnosisId}/send-back`,
            params: {
              remark: value,
            },
          });

          if (res && res.data.code === 200) {
            this.$message.success('退回成功');
            this.$router.go(-1);
          } else {
            this.$message.warning('退回失败');
          }
        })
        .catch(() => {
          this.$message.info('取消操作');
        });
    },
    // TODO 诊断 - 重新扫描
    // diagnosisRescan() {

    // },
    // 检查类型 - 变更
    checkCategoryChange() {
      this.$confirm('切换检查类型将导致填写数据丢失, 是否继续？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          await this.diagnosisCheckCategorySave();
        })
        .catch(() => {
          this.checkCategorySelected = this.diagnosis.checkCategory;
        });
    },
    // 检查类型 - 变更后保存
    async diagnosisCheckCategorySave() {
      const res = await this.$axios({
        // 详见 axios 请求配置项
        method: 'POST',
        url: `/PROXY-Remote/diagnosis/update/checkCategory`,
        data: {
          diagnosisId: this.diagnosisId,
          checkCategory: this.checkCategorySelected,
        },
      });

      if (res && res.data.code === 200) {
        this.$message.success('切换成功');
        this.diagnosis.checkCategory = this.checkCategorySelected;
        await this.diagnosisRefresh();
      } else {
        this.$message.warning(res.data.message);
        this.checkCategorySelected = this.diagnosis.checkCategory;
      }
    },
    // 依据 level 获取诊断详情
    detailGetByLevel(currentLevel) {
      const level = currentLevel === 6 ? this.diagnosisPrevLevel : currentLevel;
      return this.diagnosis.diagnosisDetailList.find(
        (t) => t.currentLevel === level && t.diagnosisType == 0
      );
    },

    // 标注数据
    annotationChange(level) {
      const current = level || this.activeLevel;
      const detail = this.detailGetByLevel(current);
      const doctorId = _.get(detail, 'doctorId', 0);
      this.annotationsList = [];
      if (this.diagnosis.annotationsList.length > 0) {
        this.diagnosis.annotationsList.forEach((t) => {
          if (t.userId === doctorId) {
            this.annotationsList.push(t);
          }
        });
      }
    },
    detailGetById(id) {
      return this.diagnosis.diagnosisDetailList.find((t) => t.id == id);
    },
    // 意见 - 查看他人时，保存表单数据到缓存，加载缓存数据到表单
    opinionTabChange(activeTab, oldActiveTab) {
      if (activeTab == 0) return;
      const that = this;
      const opinionSave = function () {
        that.detailCache = JSON.parse(JSON.stringify(that.detailForm));
      };
      const opinionLoadFromTemp = function () {
        that.detailForm = _.clone(that.detailCache);
      };
      const activeLevel = parseInt(
        that.opinionTabList.find((t) => t.name == activeTab).level,
        10
      );
      const oldActiveLevel =
        oldActiveTab == 0
          ? 0
          : parseInt(
            that.opinionTabList.find((t) => t.name == oldActiveTab).level,
            10
          );
      that.activeLevel = activeLevel;
      that.annotationChange(activeLevel);
      that.opinionLoadFromLevel(activeTab);
    },
    // 医生诊断数据
    opinionLoadFromLevel(id) {
      let that = this;
      let mActiveEntity = that.detailGetById(id);
      that.activeDoctorId = mActiveEntity.doctorId;
      that.isInvited = mActiveEntity.diagnosisType == 0 ? false : true;
      that.beClickedDoctor = mActiveEntity.doctorName; //点击那个医生 显示复制那个医生的诊断
      const detailJson = mActiveEntity.detailJson;
      that.detailForm = _.clone(detailJson);
      // 设置未填写值为空格 (不显示placeholder)
      Object.keys(that.detailForm).forEach((key) => {
        if (that.detailForm[key] === '' || that.detailForm[key] == 'null') {
          that.detailForm[key] = null;
        }
      });
      //胃镜病理36个空格没有值默认第一个 "+"
      // for (let i = 0; i < 6; i++) {
      //     for (let j = 0; j < 6; j++) {
      //         if (!that.detailForm[`selection_table_${i + 1}${j + 1}`]) {
      //             this.$set(
      //                 that.detailForm,
      //                 `selection_table_${i + 1}${j + 1}`,
      //                 '+'
      //             );
      //         }
      //     }
      // }
      for (let i = 0; i < 6; i++) {
        for (let j = 0; j < 6; j++) {
          if (!that.detailForm[`selection_table_${i + 1}${j + 1}`]) {
            this.$set(that.detailForm, `selection_table_${i + 1}${j + 1}`, '');
          }
        }
      }
      //切换医生质控数据联动
      that.qualityForm.frozenCoincidenceRate =
        mActiveEntity.frozenCoincidenceRate;
      that.qualityForm.diagnosticAccordanceRate =
        mActiveEntity.diagnosticAccordanceRate;
      that.qualityForm.diagnosticCarefulnessRate =
        mActiveEntity.diagnosticCarefulnessRate;
      that.qualityForm.biopsyQuality = mActiveEntity.biopsyQuality;
      that.qualityForm.scanQuality = mActiveEntity.scanQuality;
      //琅珈回写状态赋值
      that.isSuccessSubmitReportResult =
        mActiveEntity.isSuccessSubmitReportResult;
    },
    // 复制上一级诊断意见
    async diagnosisCopy() {
      const diagnosisType = sessionStorage.getItem('diagnosisType'); //被邀请的医生diagnosisType==1点击暂存或者复制其他医生诊断意见加上此参数
      const { detailJson } = this.diagnosis.diagnosisDetailList.find(
        (t) => t.doctorId === this.activeDoctorId
      );
      this.detailForm = _.clone(detailJson);
      const detailString = JSON.stringify(this.detailForm);
      const { state } = this.$store;
      const res = await this.$axios({
        url: `/PROXY-Remote/diagnosis/${this.diagnosisId}/next-flow`,
        method: 'PUT',
        data: {
          isTempStorage: 1,
          doctorId: state.user.id,
          detailString,
          frozenCoincidenceRate: this.qualityForm.frozenCoincidenceRate,
          diagnosticAccordanceRate: this.qualityForm.diagnosticAccordanceRate,
          diagnosticCarefulnessRate: this.qualityForm.diagnosticCarefulnessRate,
          biopsyQuality: this.qualityForm.biopsyQuality,
          scanQuality: this.qualityForm.scanQuality,
          diagnosisType: diagnosisType,
        },
      });

      if (res && res.data.code === 200) {
        this.diagnosisRefresh();
        this.$message.success('复制病理诊断成功');
      } else {
        this.$message.error('复制病理诊断失败');
      }
      // this.$confirm('是否复制上一级医生标注？', '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning',
      // }).then(async () => {
      //     const res = await this.$axios({
      //         method: 'POST',
      //         url: '/PROXY-Remote/annotations/copy',
      //         params: {
      //             diagnosisId: this.diagnosisId,
      //         },
      //     });

      //     if (res && res.data.code === 200) {
      //         this.$message.success('复制成功');
      //         if (res.data.data) {
      //             res.data.data.forEach((t) => {
      //                 const annotation = {
      //                     id: t.id,
      //                     userId: t.createUserId,
      //                     imageUrl: this.imageServiceURL + t.imageUrl,
      //                 };
      //                 this.diagnosis.annotationsList.push(annotation);
      //                 this.annotationsList.push(annotation);
      //             });
      //         }
      //     }
      // });
    },
    // 报告模板获取
    async reportTemplateRequest() {
      this.reportTemplateReady = false;
      if (!this.isAssigned) {
        return;
      }
      const res = await this.$axios({
        method: 'GET',
        url: '/PROXY-Remote/report-templates/check-category',
        params: {
          checkCategory: this.diagnosis.checkCategory,
        },
      });

      if (res && res.data.code === 200) {
        const result = res.data.data;
        this.reportTemplateCol = _.get(result, 'settingsColNum', 12);
        this.componentList = [];
        this.detailForm = _.clone({});
        this.detailCache = _.clone({});

        let { detailJson } = this.detailGetByLevel(this.diagnosisLevel);

        let selectionCount = 0;//记录取得胃窦胃体胃角等值 共6次 看满足条件的有几次赋值 其余置空
        let inputCount = 0;//记录取得胃窦胃体胃角等值几块 共6次 看满足条件的有几次赋值 其余置空
        // 加载数据到表单缓存
        result.reportTemplateComponents.forEach((t, index) => {
          // 忽略基本信息项
          if (t.bigType === 'base') {
            return;
          }
          // 为胃窦胃体胃角等可选项设置初始值
          if (t.smallType === 'selection') {
            this.detailCache[t.i] = '';
            if (
              t.i == 'selection_table_01' ||
              t.i == 'selection_table_02' ||
              t.i == 'selection_table_03' ||
              t.i == 'selection_table_04' ||
              t.i == 'selection_table_05' ||
              t.i == 'selection_table_06'
            ) {
              //如果取回来的有胃窦胃体胃角等值
              if (this.diagnosis.stomachSample) {
                let stomachSampleArr = eval("(" + this.diagnosis.stomachSample + ")")
                if (selectionCount < stomachSampleArr.length) {
                  this.detailCache[t.i] = stomachSampleArr[selectionCount].SampleName;
                  detailJson[t.i] = stomachSampleArr[selectionCount].SampleName;
                  selectionCount = selectionCount + 1
                } else {
                  this.detailCache[t.i] = null
                  detailJson[t.i] = null
                }
              } else {
                if (
                  this.detailCache[t.i] == '' ||
                  this.detailCache[t.i] == null
                ) {
                  this.detailCache[t.i] = t.selectDataJson[0];
                  detailJson[t.i] = t.selectDataJson[0];
                }
              }

            }
          }
          // 为胃窦胃体胃角等可输入项几块设置初始值
          if (t.smallType === 'input') {
            this.detailCache[t.i] = '';
            if (
              t.i == 'input_weidou' ||
              t.i == 'input_weijiao' ||
              t.i == 'input_weiti' ||
              t.i == 'input_benmen' ||
              t.i == 'input_weidi' ||
              t.i == 'input_extra_1_input'
            ) {
              //如果取回来的有胃窦胃体胃角等值
              if (this.diagnosis.stomachSample) {
                let stomachSampleArr = eval("(" + this.diagnosis.stomachSample + ")")
                if (inputCount < stomachSampleArr.length) {
                  this.detailCache[t.i] = stomachSampleArr[inputCount].SampleNum;
                  detailJson[t.i] = stomachSampleArr[inputCount].SampleNum;
                  inputCount = inputCount + 1
                } else {
                  this.detailCache[t.i] = null
                  detailJson[t.i] = null
                }
              }
            }
          }

          const item = t;
          item.index = index;
          this.componentList.push(item);
        });
        Object.keys(this.detailCache).forEach((key) => {
          this.detailCache[key] = _.get(detailJson, key, '');
        });
        // 初始化填写表单的 setter 和 getter
        this.detailForm = _.clone(this.detailCache);
        // 加载数据到表单
        const activeLevel = this.isFinished
          ? this.diagnosisPrevLevel
          : this.diagnosisLevel;

        this.opinionTabChange(
          this.diagnosis.diagnosisDetailList.find(
            (item) => this.userId == item.doctorId
          ).id,
          0
        );
      }
      this.reportTemplateReady = true;
    },
    // 报告模板组件样式
    styleString(styleJson) {
      let style = 'width: 100%; word-break:break-all;';
      Object.keys(styleJson).forEach((key) => {
        style += `${key}:${styleJson[key]};`;
      });
      return style;
    },
    // 提交对话框 - 打开
    submitDialogOpen(level, isSubmitFinalVerify) {
      if (level === 2) {
        this.submitDialog.title = '选择提交的医生';
        this.submitTable.operation[0].label = '提交';
      } else if (isSubmitFinalVerify) {
        this.submitDialog.title = '选择终审的医生';
        this.submitTable.operation[0].label = '终审';
      } else if (level === 3) {
        this.submitDialog.title = '选择提交的医生';
        this.submitTable.operation[0].label = '提交';
      }
      this.submitTableDataRequest();
    },
    // 可提交医生列表
    async submitTableDataRequest() {
      const res = await this.$axios({
        method: 'GET',
        url: `/PROXY-Remote/diagnosis/${this.diagnosisId}/next-flow-doctors`,
        // TODO 分页信息
        // params: {
        //   size: this.submitTable.pageInfo.size,
        //   page: this.submitTable.pageInfo.page - 1,
        // },
      });
      if (res && res.data.code === 200) {
        const result = res.data;
        console.log('result', result);
        // TODO 分页信息
        // this.submitTable.pageInfo = {
        //   total: result.pageInfo.total,
        //   page: result.pageInfo.page + 1,
        //   size: result.pageInfo.size,
        // };
        // 查询结果数据
        this.submitTable.data = [];
        result.data.forEach((t) => {
          const { nextFlowLevel } = t;
          const levelItem = this.userLevel.find(
            (item) => item.level === nextFlowLevel
          );
          const nextFlowLevelLabel = _.get(levelItem, 'label', '');
          this.submitTable.data.push({
            index: this.submitTable.data.length,
            id: t.id,
            name: t.name,
            medicalTitleName: t.medicalTitleName,
            nextFlowLevel,
            nextFlowLevelLabel,
            phone: t.phone,
            speciality: t.speciality,
          });
        });
        //如果只有一个可提交的医生 直接默认提交
        if (this.submitTable.data.length === 1) {
          this.submitTableSubmitConfirm(this.submitTable.data[0]);
        } else {
          this.submitDialog.visible = true;
          this.submitDialog.isReady = true;
        }
      }
    },
    submitTablePageJumpTo(val) {
      this.submitTable.pageInfo.page = val;
      this.submitTableDataRequest();
    },
    submitTableSizeChange(val) {
      this.submitTable.pageInfo.size = val;
      this.submitTableDataRequest();
    },
    submitTableButtonClick(functionKey, row) {
      this[functionKey](row);
    },
    // 提交确认
    submitTableSubmitConfirm(row) {
      let _this = this;
      const { state } = this.$store;
      this.$confirm(`是否提交至${row.name}医生？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          const detailString = JSON.stringify(this.detailForm);

          const res = await this.$axios({
            url: `/PROXY-Remote/diagnosis/${this.diagnosisId}/next-flow`,
            method: 'PUT',
            data: {
              isTempStorage: 0,
              doctorId: row.id,
              detailString,
              level: row.nextFlowLevel,
              frozenCoincidenceRate: this.qualityForm.frozenCoincidenceRate,
              diagnosticAccordanceRate:
                this.qualityForm.diagnosticAccordanceRate,
              diagnosticCarefulnessRate:
                this.qualityForm.diagnosticCarefulnessRate,
              biopsyQuality: this.qualityForm.biopsyQuality,
              scanQuality: this.qualityForm.scanQuality,
            },
          });

          if (res && res.data.code === 200) {
            this.$message.success(`已经提交给${row.name}医生`);
            this.$store.commit('setPropertyGeneral', {
              key: 'diagnosis',
              value: {
                id: state.diagnosis.id,
                pathologyId: state.diagnosis.pathologyId,
                pDiagnosisType: state.diagnosis.pDiagnosisType,
              },
            });
            localStorage.setItem('submitAfterSaveBeforeStatus', 'true'); //提交之后 上一个下一个还要是我的任务里的上一个下一个 没有提交正常流程  提交了用此状态控制保留之前的
            localStorage.prevPathologyId = this.diagnosis.previousPathologyId;
            localStorage.nextPathologyId = this.diagnosis.nextPathologyId;

            this.diagnosisRefresh();
            this.submitDialog.visible = false;
          } else {
            this.$message.error(res.data.message);
          }
        })
        .catch(() => {
          this.$message.info('取消操作');
        });
    },
    // 加做项目获取
    async extraProjectRequest() {
      try {
        await this.$axios({
          url: '/PROXY-Remote/diagnosis/extra-project/search',
          method: 'POST',
          params: {
            diagnosisId: this.diagnosisId,
            page: 0,
            size: 999,
          },
        }).then((res) => {
          if (res && res.data.code === 200) {
            this.specialExtraProjectList = [];
            this.techExtraProjectList = [];

            res.data.data.forEach((project) => {
              if (project.currLevel > 0) {
                const item = {
                  doctorType: project.doctorType,
                  doctorAdviceName: project.doctorAdviceName,
                };

                switch (item.doctorType) {
                  case 1:
                  case 2:
                  case 3:
                    this.specialExtraProjectList.push(item);
                    break;
                  case 4:
                    this.techExtraProjectList.push(item);
                    break;
                  default:
                    break;
                }
              }
            });
          }
        });
      } catch (e) {
        throw new Error(e);
      }
    },
    OpenImage(herf) {
      const width = window.screen.availWidth + 10;
      const height = window.screen.availHeight + 10;
      window.open(
        herf,
        '_blank',
        `location=no,width=${width},height=${height}`
      );
    },
    detailSpecialCheckImport() {
      const i = 'input_normal_specialCheck';
      if (this.detailForm[i] === null || this.detailForm[i] === undefined) {
        this.$message.warning("未找到'特殊检查'组件，请联系管理员");
        return;
      }

      const textGroup = [];
      this.specialExtraProjectList.forEach((t) => {
        let text = '';
        if (textGroup.length > 0 && textGroup.length % 2 === 0) {
          text += '\n';
        }
        const type = this.doctorAdviceMap.find(
          (item) => item.type === t.doctorType
        );
        text += `${type.label} ${t.doctorAdviceName}：        `;
        textGroup.push(text);
      });
      this.techExtraProjectList.forEach((t) => {
        let text = '';
        if (textGroup.length > 0 && textGroup.length % 2 === 0) {
          text += '\n';
        }
        const type = this.doctorAdviceMap.find(
          (item) => item.type === t.doctorType
        );
        text += `${type.label} ${t.doctorAdviceName}：        `;
        textGroup.push(text);
      });

      if (textGroup.length === 0) {
        this.$message.info('暂无数据导入');
      } else {
        let data = '';
        // for (const t of textGroup) { data += t; }
        textGroup.forEach((ele) => {
          data += ele;
        });
        this.detailForm[i] = data;
      }
    },
    detailSpecialCheckClear() {
      const i = 'input_normal_specialCheck';
      if (this.detailForm[i] === null || this.detailForm[i] === undefined) {
        this.$message.warning("未找到'特殊检查'组件，请联系管理员");
      } else {
        this.detailForm[i] = '';
      }
    },
    detailMicroFingingsClear() {
      const i = 'input_normal_microFingings';
      if (this.detailForm[i] === null || this.detailForm[i] === undefined) {
        this.$message.warning("未找到'镜下所见'组件，请联系管理员");
      } else {
        this.detailForm[i] = '';
      }
    },
    detailDiagnoseClear() {
      const that = this;
      const i = 'input_normal_diagnose';
      if (that.detailForm[i] === null || that.detailForm[i] === undefined) {
        that.$message.warning('未找到病理诊断组件，请联系管理员');
      } else {
        that.detailForm[i] = '';
      }
    },
    // 在父组件中改变ifShowMain的值
    changeShowMain(data) {
      this.ifShowMain = data;
    },
    // 检验项目趋势图条件
    PicSelectionItemschange() {
      if (this.PicSelectionItemsData !== '') {
        this.SelectionItemsData.forEach((temp) => {
          if (temp.value === this.PicSelectionItemsData) {
            this.$refs.bottom.qsPIC(temp.label);
          }
        });
      }
    },
    // 渲染趋势图
    getPicData(row, picVisible, filterData) {
      const filter = { eventNames: row };
      this.SelectionItemsData = filterData;
      this.picLoading = true;
      this.PICdialogVisible = picVisible;
      this.PicSelectionItemsData = row;
      let result;
      try {
        let url = `/PROXY-aiSearch/lis/special-index?page=1&patientId=${this.diagnosis.patientId}&size=1000`;
        const datas = [];
        const params = {};
        if (filter.ycts) {
          params.ycts = encodeURIComponent(filter.ycts);
        }
        if (filter.eventNames) {
          params.eventNames = encodeURIComponent(filter.eventNames);
        }
        Object.getOwnPropertyNames(params).forEach((key) => {
          const value = params[key];
          if (value) {
            datas.push(`${key}=${value}`);
          }
        });
        if (datas.length > 0) {
          url = `${url}&${datas.join('&')}`;
        }

        console.log('get-getPicData', url);
        this.$axios({
          // 详见 axios 请求配置项
          method: 'GET',
          url,
        }).then((res) => {
          // 请求失败
          if (res.data.code !== 200) {
            throw new Error(res.data);
          }
          result = res.data.data;
          console.log('result-getPicData', result);
          this.drawChart(result, row);
          // 请求成功
        });
      } catch (e) {
        // 跳出
      }
      return result;
    },
    drawChart(result, row) {
      // 基于准备好的dom，初始化echarts实例
      if (result) {
        const xAxisData = [];
        const seriesData = [];
        // 对日期进行排序
        const tempData = result.sort((a, b) =>
          a.consequence_time > b.consequence_time ? 1 : -1
        );
        tempData.forEach((a) => {
          xAxisData.push(
            moment(a.consequence_time).format('YYYY/MM/DD')
          );
          seriesData.push(a.consequence);
        })
        // for (const a of tempData) {
        //     xAxisData.push(
        //         moment(a.consequence_time).format('YYYY/MM/DD')
        //     );
        //     seriesData.push(a.consequence);
        // }
        const myChart = echarts.init(document.getElementById('examLevel'));
        // 指定图表的配置项和数据
        // let option = {
        //      title : {
        //         text:row,
        //         x: 'center',
        //     },
        //     xAxis: {
        //         type: 'category',
        //         data: xAxisData
        //     },
        //     yAxis: {
        //         type: 'value'
        //     },
        //     series: [{
        //         data:seriesData,
        //         type: 'line'
        //     }]
        // };
        const option = {
          title: {
            text: row,
            x: 'center',
          },
          tooltip: {
            trigger: 'axis',
          },
          toolbox: {
            show: false,
            feature: {
              dataZoom: {
                yAxisIndex: 'none',
              },
              dataView: { readOnly: false },
              magicType: { type: ['line', 'bar'] },
              restore: {},
              saveAsImage: {},
            },
          },
          xAxis: {
            type: 'category',
            boundaryGap: false,
            data: xAxisData,
          },
          yAxis: {
            type: 'value',
          },
          series: [
            {
              name: '数值',
              type: 'line',
              data: seriesData,
              markPoint: {
                data: [
                  {
                    type: 'max',
                    name: '最大值',
                  },
                  {
                    type: 'min',
                    name: '最小值',
                  },
                ],
              },
              markLine: {
                data: [
                  {
                    type: 'average',
                    name: '平均值',
                  },
                ],
              },
            },
          ],
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        this.picLoading = false;
      }
    },

    // 分配医生对话框 - 打开
    doctorsDialogOpen() {
      this.doctorsTable.pageInfo.page = 1;
      this.doctorsDialog.visible = true;
      this.doctorsTableDataGet();
    },
    // 获取分配专家
    async doctorsTableDataGet() {
      const id = this.diagnosisId;
      this.doctorsTable.isReady = false;

      const res = await this.$axios({
        method: 'get',
        url: `/PROXY-Remote/diagnosis/${id}/invite/doctors`,
        params: {
          page: this.doctorsTable.pageInfo.page - 1,
          size: this.doctorsTable.pageInfo.size,
        },
      });

      if (res && res.data.code === 200) {
        const result = res.data;
        this.doctorsTable.pageInfo = {
          total: result.pageInfo.total,
          page: result.pageInfo.page,
          size: result.pageInfo.size,
        };
        // this.doctorsTable.pageInfo.hide = true;

        this.doctorsTable.data = [];
        result.data.forEach((element) => {
          this.doctorsTable.data.push(element);
        });
        this.doctorsTable.isReady = true;
      } else {
        this.$message.warning('请求失败');
        this.doctorsTable.isReady = true;
      }
    },
    doctorsTablePageJumpTo(val) {
      this.doctorsTable.pageInfo.page = val;
      this.doctorsTableDataGet();
    },
    doctorsTableSizeChange(val) {
      this.doctorsTable.pageInfo.size = val;
      this.doctorsTableDataGet();
    },
    teachingLibraryTablePageJumpTo(val) {
      this.teachingLibraryTable.pageInfo.page = val;
      this.teachingLibraryTableDataGet();
    },
    teachingLibraryTableSizeChange(val) {
      this.teachingLibraryTable.pageInfo.size = val;
      this.teachingLibraryTableDataGet();
    },
    scienceLibraryTablePageJumpTo(val) {
      this.scienceLibraryTable.pageInfo.page = val;
      this.scienceLibraryTableDataGet();
    },
    scienceLibraryTableSizeChange(val) {
      this.scienceLibraryTable.pageInfo.size = val;
      this.scienceLibraryTableDataGet();
    },
    doctorsTableButtonClick(functionKey, row) {
      this[functionKey](row);
    },
    doctorsTableAssign(currentRowDocTor) {
      this.$confirm(`邀请${currentRowDocTor.name}`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          const level = _.get(currentRowDocTor, 'nextFlowLevel', 0);
          if (!level) {
            this.$message.warning('邀请失败');
            return;
          }

          const res = await this.$axios({
            method: 'GET',
            url: `/PROXY-Remote/diagnosis-detail/diagnosisDetail/${this.diagnosisId}/${currentRowDocTor.id}`,
            headers: {
              'Content-Type': 'application/json',
            },
          });

          if (res && res.data.code === 200) {
            if (this.workingStatus === 'assigning') {
              this.$message.info('重新邀请成功');
            } else {
              this.$message.info('邀请成功');
            }
            this.doctorsDialog.visible = false;
            this.$emit('diagnosisRequest');
          } else if (this.workingStatus === 'assigning') {
            this.$message.info('重新邀请失败');
          } else {
            this.$message.warning('邀请失败');
          }
        })
        .catch(() => { });
    },
    selectionChange(selection) {
      this.selectedList = selection;
    },
    handleSelectAll(row) {
      this.selectedList = row;
    },
    async batchInvite() {
      if (this.selectedList.length === 0) {
        this.$message.warning({ message: '请选择要邀请的医生' });
        return;
      }
      const res = await this.$axios({
        method: 'POST',
        url: `/diagnosis-detail/batch/diagnosisDetail`,
        data: {
          diagnosisId: this.diagnosisId,
          doctorIds: this.selectedList.map((item) => {
            return item.id;
          }),
        },
      });
      if (res && res.data.code === 200) {
        this.$message.success('批量邀请成功');
        this.doctorsDialog.visible = false;
        this.$emit('diagnosisRequest');
      } else {
        this.$message.error('批量邀请失败');
      }
    },
  },
};
</script>

<style scoped>
.diagnosis-template-tree {
  flex: 1;

  display: flex;

  align-items: center;

  justify-content: space-between;
}

.diagnosis-template-tree-message {
  font-size: 14px;

  max-width: 310px;

  overflow: hidden;

  white-space: nowrap;

  text-overflow: ellipsis;
}

.container-narrow {
  /* margin: 0 auto; */

  max-width: 800px;

  height: max-content;

  background: #ffffff;

  /*padding: 20px;*/
}

/* .container-bottom {
  display: flex;
  justify-content: space-between;
} */
.container-right {}

.button-list-item {
  /*margin-right: 10px;*/

  /*width: 90px;*/
}

.tag-list-item {
  margin-right: 10px;
}

.quality-list-item {
  width: 100px;
}

.row-in-grid-item {
  min-height: 28px;

  display: flex;

  align-items: center;
}

.annotation-row {
  padding: 10px;
  max-width: 800px;
  height: 50px;
  line-height: 50px;
  display: flex;
  width: 100%;
}

.annotation-row1 {
  /* max-width: 630px; */
  /* height: 22px; */
  /* display: flex; */
  width: 100%;
  /*width: -moz-available;          !* WebKit-based browsers will ignore this. *!*/
  /*width: -webkit-fill-available;  !* Mozilla-based browsers will ignore this. *!*/
  /*width: fill-available;*/
}

.annotation-row1 .row1-red {
  font-size: 18px;
  color: red;
  font-weight: bold;
}

/* .pathology-observed-text {
  max-width: 550px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
} */
.annotation-img {
  width: 50px;

  height: 50px;

  margin-right: 8px;

  cursor: pointer;
}

.invite-y-scroll {
  height: 472px;
  overflow: scroll;
}

/deep/ .redcolor-input .el-input__inner {
  color: red;
}

/deep/ .diagnosis-template-tree-message .el-button--text span {
  max-width: 250px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: block;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-tree {
  max-height: 800px;
  overflow-y: auto;
}

.share-qrcode-box {
  padding: 20px;
  margin: 20px auto;
  border-top: 1px solid #dcdcdc;
  display: flex;
  justify-content: space-around;
}

.activeRedBorder {
  border: 2px solid red;
  margin-left: 15px;
}
.input-form{margin: 0 10px;}
.tag-default-calss{margin-left: 15px;}
.save-btn{color: #10A1DF;border:1px solid #10A1DF;padding-left:12px;padding-right:12px;}
.ml10{margin-left: 10px;}
/* 更改grid-layout的input被禁止时的颜色 */
::v-deep .vue-grid-item .el-input.is-disabled .el-input__inner {
  color: #2c3e50;
}

::v-deep .vue-grid-item .el-textarea.is-disabled .el-textarea__inner {
  color: #2c3e50;
}
.h40{height: 40px;}
/* 兼容pad开始 */
@media only screen and (max-width: 1000px) {
    ::v-deep .el-tabs__nav-next,.el-tabs__nav-prev {
        line-height: 22px;
    }
    ::v-deep .el-tabs__header {margin: 0 0 5px;}
    ::v-deep .el-button--mini, .el-button--mini.is-round {padding: 1px 1px !important;}
    ::v-deep .el-tabs--card > .el-tabs__header .el-tabs__item {
        font-size: 12px !important;
        padding: 0 5px !important;
        height: 20px !important;
        line-height: 20px !important;
    }
    ::v-deep .h40{height: auto;}
    .overx-scroll{overflow-x: scroll;}
    .activeRedBorder{
      height: 20px;
      line-height: 19px;
      padding: 0 5px;
      margin-left: 5px;
    }
    .tag-default-calss{margin-left: 5px;}
    .tag-list-item {margin-right: 5px;}
    .input-form{margin: 0 2px;height: 18px;line-height: 18px;}
    .ml10{margin-left: 5px;}
    ::v-deep .el-input--mini .el-input__inner{height: 18px;line-height: 18px;}
    ::v-deep .el-form-item__content {line-height: 20px;}
    ::v-deep .el-form-item__label{line-height: 20px;}
    ::v-deep .line-text {line-height: 20px;}
    ::v-deep .title-medium{font-size: 12px;}
    ::v-deep .content-text{font-size: 12px;}
    ::v-deep .el-textarea__inner{padding: 5px;}
    ::v-deep .el-input--mini .el-input__icon {line-height: 20px;}
    .container-narrow {font-size: 12px;}
}
</style>
